Check firebird.log [no messages found for interval when this test was running]
Jump to: output_first_mismatch    outcomes_full_history    elapsed_time_chart
Show cross-report outcomes.

Annotation type Annotation details
2 @message
firebird.driver.types.DatabaseError: I/O error during "lock" operation for file "/home/fbqa/qa-2024/unpacked-snapshot.tmp/examples/empbuild/qa/tmp_gh_8429_c.fdb"
-Database already opened with engine instance, incompatible with current

LOG DETAILS:

2025-02-25 08:06:19.597
2025-02-25 08:06:19.608 act_a = <firebird.qa.plugin.Action object at [hex]>
2025-02-25 08:06:19.618 act_b = <firebird.qa.plugin.Action object at [hex]>
2025-02-25 08:06:19.626 act_c = <firebird.qa.plugin.Action object at [hex]>
2025-02-25 08:06:19.633 usr_x = <firebird.qa.plugin.User object at [hex]>
2025-02-25 08:06:19.639 usr_y = <firebird.qa.plugin.User object at [hex]>
2025-02-25 08:06:19.644 usr_z = <firebird.qa.plugin.User object at [hex]>
2025-02-25 08:06:19.650 capsys = <_pytest.capture.CaptureFixture object at [hex]>
2025-02-25 08:06:19.656
2025-02-25 08:06:19.664 @pytest.mark.es_eds
2025-02-25 08:06:19.670 @pytest.mark.encryption
2025-02-25 08:06:19.676 @pytest.mark.version('>=4.0.6')
2025-02-25 08:06:19.682 def test_1(act_a: Action, act_b: Action, act_c: Action, usr_x: User, usr_y: User, usr_z: User, capsys):
2025-02-25 08:06:19.687
2025-02-25 08:06:19.694 dbfile_a = get_filename_by_alias(act_a)
2025-02-25 08:06:19.702 dbfile_b = get_filename_by_alias(act_b)
2025-02-25 08:06:19.708 dbfile_c = get_filename_by_alias(act_c)
2025-02-25 08:06:19.713
2025-02-25 08:06:19.718 dbfile_a.unlink(missing_ok = True)
2025-02-25 08:06:19.723 dbfile_b.unlink(missing_ok = True)
2025-02-25 08:06:19.728 dbfile_c.unlink(missing_ok = True)
2025-02-25 08:06:19.734
2025-02-25 08:06:19.742 with create_database(act_a.db.db_path, user = act_a.db.user, password = act_a.db.password) as con_a, \
2025-02-25 08:06:19.748 create_database(act_b.db.db_path, user = act_b.db.user, password = act_b.db.password) as con_b, \
2025-02-25 08:06:19.755 create_database(act_c.db.db_path, user = act_c.db.user, password = act_c.db.password) as con_c:
2025-02-25 08:06:19.760
2025-02-25 08:06:19.766 sql = f"""
2025-02-25 08:06:19.772 create procedure sp_a (a_who varchar(31)) returns (o_info varchar(512)) as
2025-02-25 08:06:19.778 begin
2025-02-25 08:06:19.784 -- e1-meta.sql:
2025-02-25 08:06:19.791 execute statement 'select * from sp_b(''' || a_who || ''')' as user '{usr_x.name}' password '{usr_x.password}' on external 'gh_8429_alias_b' into o_info;
2025-02-25 08:06:19.797 suspend;
2025-02-25 08:06:19.802 end
2025-02-25 08:06:19.808 ^
2025-02-25 08:06:19.814 grant execute on procedure sp_a to public
2025-02-25 08:06:19.820 ^
2025-02-25 08:06:19.825 alter database set linger to 0
2025-02-25 08:06:19.831 ^
2025-02-25 08:06:19.837 """
2025-02-25 08:06:19.843 for x in sql.split('^'):
2025-02-25 08:06:19.850 if (s := x.strip()):
2025-02-25 08:06:19.855 con_a.execute_immediate(s)
2025-02-25 08:06:19.862 con_a.commit()
2025-02-25 08:06:19.869
2025-02-25 08:06:19.875 # ..................................................
2025-02-25 08:06:19.880
2025-02-25 08:06:19.886 sql = f"""
2025-02-25 08:06:19.891 create procedure sp_b (a_who varchar(31)) returns (o_info varchar(512)) as
2025-02-25 08:06:19.898 begin
2025-02-25 08:06:19.904 execute statement 'select * from sp_c' as user a_who password a_who on external 'gh_8429_alias_c' into o_info;
2025-02-25 08:06:19.910 suspend;
2025-02-25 08:06:19.915 end
2025-02-25 08:06:19.921 ^
2025-02-25 08:06:19.927 grant execute on procedure sp_b to public
2025-02-25 08:06:19.932 ^
2025-02-25 08:06:19.938 alter database set linger to 0
2025-02-25 08:06:19.945 ^
2025-02-25 08:06:19.951 """
2025-02-25 08:06:19.957 for x in sql.split('^'):
2025-02-25 08:06:19.963 if (s := x.strip()):
2025-02-25 08:06:19.969 con_b.execute_immediate(s)
2025-02-25 08:06:19.975 con_b.commit()
2025-02-25 08:06:19.980
2025-02-25 08:06:19.986 # ..................................................
2025-02-25 08:06:19.992
2025-02-25 08:06:19.997 sql = f"""
2025-02-25 08:06:20.002 create procedure sp_c returns (o_info varchar(512)) as
2025-02-25 08:06:20.008 begin
2025-02-25 08:06:20.014 o_info = lower(current_user);
2025-02-25 08:06:20.019 -- o_info = lower(rdb$get_context('SYSTEM', 'DB_NAME')) || ':' || lower(current_user);
2025-02-25 08:06:20.025 suspend;
2025-02-25 08:06:20.031 end
2025-02-25 08:06:20.037 ^
2025-02-25 08:06:20.043 grant execute on procedure sp_c to public
2025-02-25 08:06:20.048 ^
2025-02-25 08:06:20.053 alter database set linger to 0
2025-02-25 08:06:20.058 ^
2025-02-25 08:06:20.064 """
2025-02-25 08:06:20.071 for x in sql.split('^'):
2025-02-25 08:06:20.076 if (s := x.strip()):
2025-02-25 08:06:20.082 con_c.execute_immediate(s)
2025-02-25 08:06:20.088 con_c.commit()
2025-02-25 08:06:20.094
2025-02-25 08:06:20.101 ############################################
2025-02-25 08:06:20.107 ###   E N C R Y P T    D A T A B A S E   ###
2025-02-25 08:06:20.113 ############################################
2025-02-25 08:06:20.119 >           run_encr_decr(act_c, 'encrypt', MAX_WAITING_ENCR_FINISH, capsys)
2025-02-25 08:06:20.126
2025-02-25 08:06:20.132 tests/bugs/gh_8429_test.py:272:
2025-02-25 08:06:20.139 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-02-25 08:06:20.145
2025-02-25 08:06:20.151 act = <firebird.qa.plugin.Action object at [hex]>, mode = 'encrypt'
2025-02-25 08:06:20.157 max_wait_encr_thread_finish = 10000
2025-02-25 08:06:20.163 capsys = <_pytest.capture.CaptureFixture object at [hex]>
2025-02-25 08:06:20.168
2025-02-25 08:06:20.174 def run_encr_decr(act: Action, mode, max_wait_encr_thread_finish, capsys):
2025-02-25 08:06:20.180 if mode == 'encrypt':
2025-02-25 08:06:20.186 # See letter from Alex, 15.12.2023 16:16 demo-plugin can not transfer named key over network.
2025-02-25 08:06:20.192 # Because of that, we have to use 'ALTER DATABASE ENCRYPT WITH <plugin>'  _WITHOUT_ adding 'key "{ENCRYPTION_KEY}"'.
2025-02-25 08:06:20.198 # ::: NB ::: One need to be sure that $FB_HOME/plugins.conf contains following lines:
2025-02-25 08:06:20.204 # Plugin = KH2 {
2025-02-25 08:06:20.211 #     Module = $(dir_plugins)/fbSampleKeyHolder
2025-02-25 08:06:20.216 #     RegisterName = fbSampleKeyHolder
2025-02-25 08:06:20.222 #     Config = KH2
2025-02-25 08:06:20.228 # }
2025-02-25 08:06:20.234 #  Config = KH2 {
2025-02-25 08:06:20.239 #     Auto = false
2025-02-25 08:06:20.245 # }
2025-02-25 08:06:20.251 # Otherwise error will raise:
2025-02-25 08:06:20.256 # unsuccessful metadata update
2025-02-25 08:06:20.262 # -ALTER DATABASE failed
2025-02-25 08:06:20.269 # -Missing database encryption key for your attachment
2025-02-25 08:06:20.275 # -Plugin fbSampleDbCrypt:
2025-02-25 08:06:20.280 # -Crypt key not set
2025-02-25 08:06:20.286 #
2025-02-25 08:06:20.292 alter_db_sttm = f'alter database encrypt with "{ENCRYPTION_PLUGIN}"' # <<< ::: NB ::: DO NOT add '... key "{ENCRYPTION_KEY}"' here!
2025-02-25 08:06:20.298 wait_for_state = 'Database encrypted'
2025-02-25 08:06:20.304 elif mode == 'decrypt':
2025-02-25 08:06:20.310 alter_db_sttm = 'alter database decrypt'
2025-02-25 08:06:20.316 wait_for_state = 'Database not encrypted'
2025-02-25 08:06:20.322
2025-02-25 08:06:20.327
2025-02-25 08:06:20.335 e_thread_finished = False
2025-02-25 08:06:20.344
2025-02-25 08:06:20.351 # 0 = non crypted;
2025-02-25 08:06:20.358 # 1 = has been encrypted;
2025-02-25 08:06:20.365 # 2 = is DEcrypting;
2025-02-25 08:06:20.372 # 3 = is Encrypting;
2025-02-25 08:06:20.382 #
2025-02-25 08:06:20.393 REQUIRED_CRYPT_STATE = 1 if mode == 'encrypt' else 0
2025-02-25 08:06:20.401 current_crypt_state = -1
2025-02-25 08:06:20.409 d1 = py_dt.timedelta(0)
2025-02-25 08:06:20.421 >       with act.db.connect() as con:
2025-02-25 08:06:20.432
2025-02-25 08:06:20.440 tests/bugs/gh_8429_test.py:147:
2025-02-25 08:06:20.448 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-02-25 08:06:20.454
2025-02-25 08:06:20.461 database = 'gh_8429_alias_c'
2025-02-25 08:06:20.468
2025-02-25 08:06:20.474 def connect(database: str, *, user: str=None, password: str=None, role: str=None,
2025-02-25 08:06:20.480 no_gc: bool=None, no_db_triggers: bool=None, dbkey_scope: DBKeyScope=None,
2025-02-25 08:06:20.486 crypt_callback: iCryptKeyCallbackImpl=None, charset: str=None,
2025-02-25 08:06:20.493 auth_plugin_list: str=None, session_time_zone: str=None) -> Connection:
2025-02-25 08:06:20.500 """Establishes a connection to the database.
2025-02-25 08:06:20.505
2025-02-25 08:06:20.511 Arguments:
2025-02-25 08:06:20.516 database: DSN or Database configuration name.
2025-02-25 08:06:20.521 user: User name.
2025-02-25 08:06:20.527 password: User password.
2025-02-25 08:06:20.532 role: User role.
2025-02-25 08:06:20.539 no_gc: Do not perform garbage collection for this connection.
2025-02-25 08:06:20.546 no_db_triggers: Do not execute database triggers for this connection.
2025-02-25 08:06:20.552 dbkey_scope: DBKEY scope override for connection.
2025-02-25 08:06:20.560 crypt_callback: Callback that provides encryption key for the database.
2025-02-25 08:06:20.571 charset: Character set for connection.
2025-02-25 08:06:20.583 auth_plugin_list: List of authentication plugins override
2025-02-25 08:06:20.593 session_time_zone: Session time zone [Firebird 4]
2025-02-25 08:06:20.600
2025-02-25 08:06:20.610 Hooks:
2025-02-25 08:06:20.619 Event `.ConnectionHook.ATTACH_REQUEST`: Executed after all parameters
2025-02-25 08:06:20.625 are preprocessed and before `Connection` is created. Hook
2025-02-25 08:06:20.631 must have signature::
2025-02-25 08:06:20.636
2025-02-25 08:06:20.642 hook_func(dsn: str, dpb: bytes) -> Optional[Connection]
2025-02-25 08:06:20.648
2025-02-25 08:06:20.654 Hook may return `Connection` instance or None.
2025-02-25 08:06:20.660 First instance returned by any hook will become the return value
2025-02-25 08:06:20.672 of this function and other hooks are not called.
2025-02-25 08:06:20.682
2025-02-25 08:06:20.694 Event `.ConnectionHook.ATTACHED`: Executed before `Connection` instance is
2025-02-25 08:06:20.708 returned. Hook must have signature::
2025-02-25 08:06:20.717
2025-02-25 08:06:20.726 hook_func(connection: Connection) -> None
2025-02-25 08:06:20.741
2025-02-25 08:06:20.755 Any value returned by hook is ignored.
2025-02-25 08:06:20.768 """
2025-02-25 08:06:20.781 db_config = driver_config.get_database(database)
2025-02-25 08:06:20.793 if db_config is None:
2025-02-25 08:06:20.806 db_config = driver_config.db_defaults
2025-02-25 08:06:20.822 else:
2025-02-25 08:06:20.834 database = db_config.database.value
2025-02-25 08:06:20.846 if db_config.server.value is None:
2025-02-25 08:06:20.858 srv_config = driver_config.server_defaults
2025-02-25 08:06:20.872 else:
2025-02-25 08:06:20.885 srv_config = driver_config.get_server(db_config.server.value)
2025-02-25 08:06:20.893 if srv_config is None:
2025-02-25 08:06:20.900 raise ValueError(f"Configuration for server '{db_config.server.value}' not found")
2025-02-25 08:06:20.907 if user is None:
2025-02-25 08:06:20.913 user = db_config.user.value
2025-02-25 08:06:20.919 if user is None:
2025-02-25 08:06:20.925 user = srv_config.user.value
2025-02-25 08:06:20.930 if password is None:
2025-02-25 08:06:20.937 password = db_config.password.value
2025-02-25 08:06:20.954 if password is None:
2025-02-25 08:06:20.965 password = srv_config.password.value
2025-02-25 08:06:20.973 if role is None:
2025-02-25 08:06:20.980 role = db_config.role.value
2025-02-25 08:06:20.987 if charset is None:
2025-02-25 08:06:20.995 charset = db_config.charset.value
2025-02-25 08:06:21.006 if charset:
2025-02-25 08:06:21.014 charset = charset.upper()
2025-02-25 08:06:21.029 if auth_plugin_list is None:
2025-02-25 08:06:21.037 auth_plugin_list = db_config.auth_plugin_list.value
2025-02-25 08:06:21.046 if session_time_zone is None:
2025-02-25 08:06:21.061 session_time_zone = db_config.session_time_zone.value
2025-02-25 08:06:21.074 dsn = _connect_helper(db_config.dsn.value, srv_config.host.value, srv_config.port.value,
2025-02-25 08:06:21.083 database, db_config.protocol.value)
2025-02-25 08:06:21.091 dpb = DPB(user=user, password=password, role=role, trusted_auth=db_config.trusted_auth.value,
2025-02-25 08:06:21.098 sql_dialect=db_config.sql_dialect.value, timeout=db_config.timeout.value,
2025-02-25 08:06:21.113 charset=charset, cache_size=db_config.cache_size.value,
2025-02-25 08:06:21.126 no_linger=db_config.no_linger.value, utf8filename=db_config.utf8filename.value,
2025-02-25 08:06:21.135 no_gc=no_gc, no_db_triggers=no_db_triggers, dbkey_scope=dbkey_scope,
2025-02-25 08:06:21.143 dummy_packet_interval=db_config.dummy_packet_interval.value,
2025-02-25 08:06:21.151 config=db_config.config.value, auth_plugin_list=auth_plugin_list,
2025-02-25 08:06:21.157 session_time_zone=session_time_zone, set_bind=db_config.set_bind.value,
2025-02-25 08:06:21.164 decfloat_round=db_config.decfloat_round.value,
2025-02-25 08:06:21.171 decfloat_traps=db_config.decfloat_traps.value,
2025-02-25 08:06:21.179 parallel_workers=db_config.parallel_workers.value)
2025-02-25 08:06:21.195 >       return __make_connection(False, dsn, db_config.utf8filename.value, dpb.get_buffer(),
2025-02-25 08:06:21.206 db_config.sql_dialect.value, charset, crypt_callback)
2025-02-25 08:06:21.216
2025-02-25 08:06:21.224 ../lib/python3.11/site-packages/firebird/driver/core.py:2149:
2025-02-25 08:06:21.232 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-02-25 08:06:21.241
2025-02-25 08:06:21.248 create = False, dsn = 'localhost/3708:gh_8429_alias_c', utf8filename = False
2025-02-25 08:06:21.256 dpb = b'\x01\x1c\x06SYSDBA\x1d\tmasterkey?\x04\x03\x00\x00\x00', sql_dialect = 3
2025-02-25 08:06:21.262 charset = None, crypt_callback = None
2025-02-25 08:06:21.271
2025-02-25 08:06:21.278 def __make_connection(create: bool, dsn: str, utf8filename: bool, dpb: bytes,
2025-02-25 08:06:21.285 sql_dialect: int, charset: str,
2025-02-25 08:06:21.296 crypt_callback: iCryptKeyCallbackImpl) -> Connection:
2025-02-25 08:06:21.304 with a.get_api().master.get_dispatcher() as provider:
2025-02-25 08:06:21.316 if crypt_callback is not None:
2025-02-25 08:06:21.330 provider.set_dbcrypt_callback(crypt_callback)
2025-02-25 08:06:21.345 if create:
2025-02-25 08:06:21.361 att = provider.create_database(dsn, dpb, 'utf-8' if utf8filename else FS_ENCODING)
2025-02-25 08:06:21.378 con = Connection(att, dsn, dpb, sql_dialect, charset)
2025-02-25 08:06:21.390 else:
2025-02-25 08:06:21.398 con = None
2025-02-25 08:06:21.405 for hook in get_callbacks(ConnectionHook.ATTACH_REQUEST, Connection):
2025-02-25 08:06:21.411 try:
2025-02-25 08:06:21.418 con = hook(dsn, dpb)
2025-02-25 08:06:21.425 except Exception as e:
2025-02-25 08:06:21.432 raise InterfaceError("Error in DATABASE_ATTACH_REQUEST hook.", *e.args) from e
2025-02-25 08:06:21.438 if con is not None:
2025-02-25 08:06:21.448 break
2025-02-25 08:06:21.460 if con is None:
2025-02-25 08:06:21.470 >                   att = provider.attach_database(dsn, dpb, 'utf-8' if utf8filename else FS_ENCODING)
2025-02-25 08:06:21.478
2025-02-25 08:06:21.486 ../lib/python3.11/site-packages/firebird/driver/core.py:2064:
2025-02-25 08:06:21.499 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-02-25 08:06:21.508
2025-02-25 08:06:21.516 self = <firebird.driver.interfaces.iProvider object at [hex]>
2025-02-25 08:06:21.523 filename = 'localhost/3708:gh_8429_alias_c'
2025-02-25 08:06:21.532 dpb = b'\x01\x1c\x06SYSDBA\x1d\tmasterkey?\x04\x03\x00\x00\x00'
2025-02-25 08:06:21.544 encoding = 'utf-8'
2025-02-25 08:06:21.553
2025-02-25 08:06:21.563 def attach_database(self, filename: str, dpb: Optional[bytes] = None, encoding: str = 'ascii') -> iAttachment:
2025-02-25 08:06:21.574 "Replaces `isc_attach_database()`"
2025-02-25 08:06:21.584 result = self.vtable.attachDatabase(self, self.status, filename.encode(encoding),
2025-02-25 08:06:21.598 0 if dpb is None else len(dpb), dpb)
2025-02-25 08:06:21.610 >       self._check()
2025-02-25 08:06:21.621
2025-02-25 08:06:21.634 ../lib/python3.11/site-packages/firebird/driver/interfaces.py:1295:
2025-02-25 08:06:21.643 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-02-25 08:06:21.652
2025-02-25 08:06:21.660 self = <firebird.driver.interfaces.iProvider object at [hex]>
2025-02-25 08:06:21.667
2025-02-25 08:06:21.677 def _check(self) -> None:
2025-02-25 08:06:21.691 state = self.status.get_state()
2025-02-25 08:06:21.704 if StateFlag.ERRORS in state:
2025-02-25 08:06:21.715 >           raise self.__report(DatabaseError, self.status.get_errors())
2025-02-25 08:06:21.727 E           firebird.driver.types.DatabaseError: I/O error during "lock" operation for file "/home/fbqa/qa-2024/unpacked-snapshot.tmp/examples/empbuild/qa/tmp_gh_8429_c.fdb"
2025-02-25 08:06:21.742 E           -Database already opened with engine instance, incompatible with current
2025-02-25 08:06:21.755
2025-02-25 08:06:21.765 ../lib/python3.11/site-packages/firebird/driver/interfaces.py:113: DatabaseError
2025-02-25 08:06:21.776 ---------------------------- Captured stdout setup -----------------------------
2025-02-25 08:06:21.789 Creating db: localhost:/var/tmp/qa_2024/test_11575/test.fdb [page_size=None, sql_dialect=None, charset='NONE', user=SYSDBA, password=masterkey]
2025-02-25 08:06:21.802 CREATE user: TMP_8429_X PLUGIN: Srp
2025-02-25 08:06:21.814 CREATE user: TMP_8429_Y PLUGIN: Srp
2025-02-25 08:06:21.827 CREATE user: TMP_8429_Z PLUGIN: Srp
2025-02-25 08:06:21.838 --------------------------- Captured stdout teardown ---------------------------
2025-02-25 08:06:21.852 DROP user: TMP_8429_Z PLUGIN: Srp
2025-02-25 08:06:21.864 DROP user: TMP_8429_Y PLUGIN: Srp
2025-02-25 08:06:21.877 DROP user: TMP_8429_X PLUGIN: Srp
3 #text
act_a = <firebird.qa.plugin.Action pytest object at [hex]>
act_b = <firebird.qa.plugin.Action pytest object at [hex]>
act_c = <firebird.qa.plugin.Action pytest object at [hex]>
usr_x = <firebird.qa.plugin.User pytest object at [hex]>
usr_y = <firebird.qa.plugin.User pytest object at [hex]>
usr_z = <firebird.qa.plugin.User pytest object at [hex]>
capsys = <_pytest.capture.CaptureFixture pytest object at [hex]>

    @pytest.mark.es_eds
    @pytest.mark.encryption
    @pytest.mark.version('>=4.0.6')
    def test_1(act_a: Action, act_b: Action, act_c: Action, usr_x: User, usr_y: User, usr_z: User, capsys):
    
        dbfile_a = get_filename_by_alias(act_a)
        dbfile_b = get_filename_by_alias(act_b)
        dbfile_c = get_filename_by_alias(act_c)
    
        dbfile_a.unlink(missing_ok = True)
        dbfile_b.unlink(missing_ok = True)
        dbfile_c.unlink(missing_ok = True)
    
        with create_database(act_a.db.db_path, user = act_a.db.user, password = act_a.db.password) as con_a, \
            create_database(act_b.db.db_path, user = act_b.db.user, password = act_b.db.password) as con_b, \
            create_database(act_c.db.db_path, user = act_c.db.user, password = act_c.db.password) as con_c:
    
            sql = f"""
                create procedure sp_a (a_who varchar(31)) returns (o_info varchar(512)) as
                begin
                    -- e1-meta.sql:
                    execute statement 'select * from sp_b(''' || a_who || ''')' as user '{usr_x.name}' password '{usr_x.password}' on external 'gh_8429_alias_b' into o_info;
                    suspend;
                end
                ^
                grant execute on procedure sp_a to public
                ^
                alter database set linger to 0
                ^
            """
            for x in sql.split('^'):
                if (s := x.strip()):
                    con_a.execute_immediate(s)
            con_a.commit()
    
            # ..................................................
    
            sql = f"""
                create procedure sp_b (a_who varchar(31)) returns (o_info varchar(512)) as
                begin
                    execute statement 'select * from sp_c' as user a_who password a_who on external 'gh_8429_alias_c' into o_info;
                    suspend;
                end
                ^
                grant execute on procedure sp_b to public
                ^
                alter database set linger to 0
                ^
            """
            for x in sql.split('^'):
                if (s := x.strip()):
                    con_b.execute_immediate(s)
            con_b.commit()
    
            # ..................................................
    
            sql = f"""
                create procedure sp_c returns (o_info varchar(512)) as
                begin
                    o_info = lower(current_user);
                    -- o_info = lower(rdb$get_context('SYSTEM', 'DB_NAME')) || ':' || lower(current_user);
                    suspend;
                end
                ^
                grant execute on procedure sp_c to public
                ^
                alter database set linger to 0
                ^
            """
            for x in sql.split('^'):
                if (s := x.strip()):
                    con_c.execute_immediate(s)
            con_c.commit()
    
            ############################################
            ###   E N C R Y P T    D A T A B A S E   ###
            ############################################
>           run_encr_decr(act_c, 'encrypt', MAX_WAITING_ENCR_FINISH, capsys)

tests/bugs/gh_8429_test.py:272: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

act = <firebird.qa.plugin.Action pytest object at [hex]>, mode = 'encrypt'
max_wait_encr_thread_finish = 10000
capsys = <_pytest.capture.CaptureFixture pytest object at [hex]>

    def run_encr_decr(act: Action, mode, max_wait_encr_thread_finish, capsys):
        if mode == 'encrypt':
            # See letter from Alex, 15.12.2023 16:16 demo-plugin can not transfer named key over network.
            # Because of that, we have to use 'ALTER DATABASE ENCRYPT WITH <plugin>'  _WITHOUT_ adding 'key "{ENCRYPTION_KEY}"'.
            # ::: NB ::: One need to be sure that $FB_HOME/plugins.conf contains following lines:
            # Plugin = KH2 {
            #     Module = $(dir_plugins)/fbSampleKeyHolder
            #     RegisterName = fbSampleKeyHolder
            #     Config = KH2
            # }
            #  Config = KH2 {
            #     Auto = false
            # }
            # Otherwise error will raise:
            # unsuccessful metadata update
            # -ALTER DATABASE failed
            # -Missing database encryption key for your attachment
            # -Plugin fbSampleDbCrypt:
            # -Crypt key not set
            #
            alter_db_sttm = f'alter database encrypt with "{ENCRYPTION_PLUGIN}"' # <<< ::: NB ::: DO NOT add '... key "{ENCRYPTION_KEY}"' here!
            wait_for_state = 'Database encrypted'
        elif mode == 'decrypt':
            alter_db_sttm = 'alter database decrypt'
            wait_for_state = 'Database not encrypted'
    
    
        e_thread_finished = False
    
        # 0 = non crypted;
        # 1 = has been encrypted;
        # 2 = is DEcrypting;
        # 3 = is Encrypting;
        #
        REQUIRED_CRYPT_STATE = 1 if mode == 'encrypt' else 0
        current_crypt_state = -1
        d1 = py_dt.timedelta(0)
>       with act.db.connect() as con:

tests/bugs/gh_8429_test.py:147: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

database = 'gh_8429_alias_c'

    def connect(database: str, *, user: str=None, password: str=None, role: str=None,
                no_gc: bool=None, no_db_triggers: bool=None, dbkey_scope: DBKeyScope=None,
                crypt_callback: iCryptKeyCallbackImpl=None, charset: str=None,
                auth_plugin_list: str=None, session_time_zone: str=None) -> Connection:
        """Establishes a connection to the database.
    
        Arguments:
            database: DSN or Database configuration name.
            user: User name.
            password: User password.
            role: User role.
            no_gc: Do not perform garbage collection for this connection.
            no_db_triggers: Do not execute database triggers for this connection.
            dbkey_scope: DBKEY scope override for connection.
            crypt_callback: Callback that provides encryption key for the database.
            charset: Character set for connection.
            auth_plugin_list: List of authentication plugins override
            session_time_zone: Session time zone [Firebird 4]
    
        Hooks:
            Event `.ConnectionHook.ATTACH_REQUEST`: Executed after all parameters
            are preprocessed and before `Connection` is created. Hook
            must have signature::
    
                hook_func(dsn: str, dpb: bytes) -> Optional[Connection]
    
            Hook may return `Connection` instance or None.
            First instance returned by any hook will become the return value
            of this function and other hooks are not called.
    
            Event `.ConnectionHook.ATTACHED`: Executed before `Connection` instance is
            returned. Hook must have signature::
    
                hook_func(connection: Connection) -> None
    
            Any value returned by hook is ignored.
        """
        db_config = driver_config.get_database(database)
        if db_config is None:
            db_config = driver_config.db_defaults
        else:
            database = db_config.database.value
        if db_config.server.value is None:
            srv_config = driver_config.server_defaults
        else:
            srv_config = driver_config.get_server(db_config.server.value)
            if srv_config is None:
                raise ValueError(f"Configuration for server '{db_config.server.value}' not found")
        if user is None:
            user = db_config.user.value
            if user is None:
                user = srv_config.user.value
        if password is None:
            password = db_config.password.value
            if password is None:
                password = srv_config.password.value
        if role is None:
            role = db_config.role.value
        if charset is None:
            charset = db_config.charset.value
        if charset:
            charset = charset.upper()
        if auth_plugin_list is None:
            auth_plugin_list = db_config.auth_plugin_list.value
        if session_time_zone is None:
            session_time_zone = db_config.session_time_zone.value
        dsn = _connect_helper(db_config.dsn.value, srv_config.host.value, srv_config.port.value,
                              database, db_config.protocol.value)
        dpb = DPB(user=user, password=password, role=role, trusted_auth=db_config.trusted_auth.value,
                  sql_dialect=db_config.sql_dialect.value, timeout=db_config.timeout.value,
                  charset=charset, cache_size=db_config.cache_size.value,
                  no_linger=db_config.no_linger.value, utf8filename=db_config.utf8filename.value,
                  no_gc=no_gc, no_db_triggers=no_db_triggers, dbkey_scope=dbkey_scope,
                  dummy_packet_interval=db_config.dummy_packet_interval.value,
                  config=db_config.config.value, auth_plugin_list=auth_plugin_list,
                  session_time_zone=session_time_zone, set_bind=db_config.set_bind.value,
                  decfloat_round=db_config.decfloat_round.value,
                  decfloat_traps=db_config.decfloat_traps.value,
                  parallel_workers=db_config.parallel_workers.value)
>       return __make_connection(False, dsn, db_config.utf8filename.value, dpb.get_buffer(),
                                 db_config.sql_dialect.value, charset, crypt_callback)

../lib/python3.11/site-packages/firebird/driver/core.py:2149: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

create = False, dsn = 'localhost/3708:gh_8429_alias_c', utf8filename = False
dpb = b'\x01\x1c\x06SYSDBA\x1d\tmasterkey?\x04\x03\x00\x00\x00', sql_dialect = 3
charset = None, crypt_callback = None

    def __make_connection(create: bool, dsn: str, utf8filename: bool, dpb: bytes,
                          sql_dialect: int, charset: str,
                          crypt_callback: iCryptKeyCallbackImpl) -> Connection:
        with a.get_api().master.get_dispatcher() as provider:
            if crypt_callback is not None:
                provider.set_dbcrypt_callback(crypt_callback)
            if create:
                att = provider.create_database(dsn, dpb, 'utf-8' if utf8filename else FS_ENCODING)
                con = Connection(att, dsn, dpb, sql_dialect, charset)
            else:
                con = None
                for hook in get_callbacks(ConnectionHook.ATTACH_REQUEST, Connection):
                    try:
                        con = hook(dsn, dpb)
                    except Exception as e:
                        raise InterfaceError("Error in DATABASE_ATTACH_REQUEST hook.", *e.args) from e
                    if con is not None:
                        break
                if con is None:
>                   att = provider.attach_database(dsn, dpb, 'utf-8' if utf8filename else FS_ENCODING)

../lib/python3.11/site-packages/firebird/driver/core.py:2064: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <firebird.driver.interfaces.iProvider pytest object at [hex]>
filename = 'localhost/3708:gh_8429_alias_c'
dpb = b'\x01\x1c\x06SYSDBA\x1d\tmasterkey?\x04\x03\x00\x00\x00'
encoding = 'utf-8'

    def attach_database(self, filename: str, dpb: Optional[bytes] = None, encoding: str = 'ascii') -> iAttachment:
        "Replaces `isc_attach_database()`"
        result = self.vtable.attachDatabase(self, self.status, filename.encode(encoding),
                                            0 if dpb is None else len(dpb), dpb)
>       self._check()

../lib/python3.11/site-packages/firebird/driver/interfaces.py:1295: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <firebird.driver.interfaces.iProvider pytest object at [hex]>

    def _check(self) -> None:
        state = self.status.get_state()
        if StateFlag.ERRORS in state:
>           raise self.__report(DatabaseError, self.status.get_errors())
E           firebird.driver.types.DatabaseError: I/O error during "lock" operation for file "/home/fbqa/qa-2024/unpacked-snapshot.tmp/examples/empbuild/qa/tmp_gh_8429_c.fdb"
E           -Database already opened with engine instance, incompatible with current

../lib/python3.11/site-packages/firebird/driver/interfaces.py:113: DatabaseError
Full history of outcomes and elapsed time, ms:
NN SNAP_INFO CS_outcome SS_outcome CS_run_time SS_run_time CS_run_beg CS_run_end SS_run_beg SS_run_end
1 4.0.6.3215 2025.06.25 6461d P P 3490 2679 2025.06.26 07:53:18.467 2025.06.26 07:53:21.957 2025.06.26 06:44:39.426 2025.06.26 06:44:42.105
2 4.0.6.3214 2025.06.21 e11f6 P P 3534 2770 2025.06.25 07:53:19.488 2025.06.25 07:53:23.022 2025.06.25 06:44:13.848 2025.06.25 06:44:16.618
3 4.0.6.3213 2025.06.14 f015c P P 3424 2697 2025.06.21 07:29:45.366 2025.06.21 07:29:48.790 2025.06.21 06:20:38.570 2025.06.21 06:20:41.267
4 4.0.6.3212 2025.06.11 bc50d P P 3560 2640 2025.06.14 08:39:01.711 2025.06.14 08:39:05.271 2025.06.14 07:18:46.434 2025.06.14 07:18:49.074
5 4.0.6.3208 2025.06.10 19fe3 P P 3994 2989 2025.06.11 07:16:27.309 2025.06.11 07:16:31.303 2025.06.11 05:57:42.800 2025.06.11 05:57:45.789
6 4.0.6.3207 2025.06.07 205ff P P 4035 3108 2025.06.10 07:19:08.231 2025.06.10 07:19:12.266 2025.06.10 05:59:06.459 2025.06.10 05:59:09.567
7 4.0.6.3206 2025.05.22 d7d10 P P 4064 2954 2025.06.06 07:24:51.918 2025.06.06 07:24:55.982 2025.06.06 06:04:47.376 2025.06.06 06:04:50.330
8 4.0.6.3205 2025.05.07 00148 P P 4130 3175 2025.05.21 07:19:01.915 2025.05.21 07:19:06.045 2025.05.21 05:58:10.641 2025.05.21 05:58:13.816
9 4.0.6.3204 2025.05.06 35b85 P P 4050 2975 2025.05.07 06:51:16.478 2025.05.07 06:51:20.528 2025.05.07 05:31:46.672 2025.05.07 05:31:49.647
10 4.0.6.3203 2025.05.05 c2cbd P P 4012 2973 2025.05.06 06:57:33.299 2025.05.06 06:57:37.311 2025.05.06 05:28:44.433 2025.05.06 05:28:47.406
11 4.0.6.3200 2025.04.18 7ef56 P P 4051 3009 2025.05.01 06:39:18.282 2025.05.01 06:39:22.333 2025.05.01 05:20:02.967 2025.05.01 05:20:05.976
12 4.0.6.3199 2025.04.14 33a10 P P 4018 3070 2025.04.18 06:50:17.468 2025.04.18 06:50:21.486 2025.04.18 05:30:38.380 2025.04.18 05:30:41.450
13 4.0.6.3198 2025.04.13 64a7f P P 3782 2834 2025.04.14 05:55:18.007 2025.04.14 05:55:21.789 2025.04.14 04:42:02.465 2025.04.14 04:42:05.299
14 4.0.6.3195 2025.03.28 b9faf P P 3695 2859 2025.04.13 05:53:20.272 2025.04.13 05:53:23.967 2025.04.13 04:30:43.987 2025.04.13 04:30:46.846
15 4.0.6.3194 2025.03.26 912aa P P 3705 2836 2025.03.28 06:24:38.784 2025.03.28 06:24:42.489 2025.03.28 05:07:47.481 2025.03.28 05:07:50.317
16 4.0.6.3193 2025.03.20 80234 P P 4105 3031 2025.03.24 06:43:06.840 2025.03.24 06:43:10.945 2025.03.24 05:21:50.851 2025.03.24 05:21:53.882
17 4.0.6.3192 2025.03.13 2a9da P P 669 464 2025.03.17 03:25:06.367 2025.03.17 03:25:07.036 2025.03.17 02:04:28.655 2025.03.17 02:04:29.119
18 4.0.6.3191 2025.03.10 3d9fd P P 677 513 2025.03.13 06:34:02.917 2025.03.13 06:34:03.594 2025.03.13 05:12:03.092 2025.03.13 05:12:03.605
19 4.0.6.3190 2025.02.25 c9928 P P 700 470 2025.03.09 06:19:50.981 2025.03.09 06:19:51.681 2025.03.09 04:59:20.571 2025.03.09 04:59:21.041
20 4.0.6.3189 2025.02.22 3fb0b P F 677 425 2025.02.25 06:09:45.154 2025.02.25 06:09:45.831 2025.02.25 04:50:40.884 2025.02.25 04:50:41.309

Elapsed time, ms. Chart for last 20 runs:

Last commits information (all timestamps in UTC):