Show firebird.log [FOUND messages 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 15:46:02.476
2025-02-25 15:46:02.486 act_a = <firebird.qa.plugin.Action object at [hex]>
2025-02-25 15:46:02.495 act_b = <firebird.qa.plugin.Action object at [hex]>
2025-02-25 15:46:02.505 act_c = <firebird.qa.plugin.Action object at [hex]>
2025-02-25 15:46:02.518 usr_x = <firebird.qa.plugin.User object at [hex]>
2025-02-25 15:46:02.531 usr_y = <firebird.qa.plugin.User object at [hex]>
2025-02-25 15:46:02.541 usr_z = <firebird.qa.plugin.User object at [hex]>
2025-02-25 15:46:02.549 capsys = <_pytest.capture.CaptureFixture object at [hex]>
2025-02-25 15:46:02.557
2025-02-25 15:46:02.566 @pytest.mark.es_eds
2025-02-25 15:46:02.580 @pytest.mark.encryption
2025-02-25 15:46:02.592 @pytest.mark.version('>=4.0.6')
2025-02-25 15:46:02.604 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 15:46:02.612
2025-02-25 15:46:02.624 dbfile_a = get_filename_by_alias(act_a)
2025-02-25 15:46:02.635 dbfile_b = get_filename_by_alias(act_b)
2025-02-25 15:46:02.643 dbfile_c = get_filename_by_alias(act_c)
2025-02-25 15:46:02.651
2025-02-25 15:46:02.657 dbfile_a.unlink(missing_ok = True)
2025-02-25 15:46:02.664 dbfile_b.unlink(missing_ok = True)
2025-02-25 15:46:02.671 dbfile_c.unlink(missing_ok = True)
2025-02-25 15:46:02.678
2025-02-25 15:46:02.689 with create_database(act_a.db.db_path, user = act_a.db.user, password = act_a.db.password) as con_a, \
2025-02-25 15:46:02.698 create_database(act_b.db.db_path, user = act_b.db.user, password = act_b.db.password) as con_b, \
2025-02-25 15:46:02.706 create_database(act_c.db.db_path, user = act_c.db.user, password = act_c.db.password) as con_c:
2025-02-25 15:46:02.715
2025-02-25 15:46:02.725 sql = f"""
2025-02-25 15:46:02.738 create procedure sp_a (a_who varchar(31)) returns (o_info varchar(512)) as
2025-02-25 15:46:02.747 begin
2025-02-25 15:46:02.756 -- e1-meta.sql:
2025-02-25 15:46:02.764 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 15:46:02.772 suspend;
2025-02-25 15:46:02.779 end
2025-02-25 15:46:02.785 ^
2025-02-25 15:46:02.791 grant execute on procedure sp_a to public
2025-02-25 15:46:02.798 ^
2025-02-25 15:46:02.804 alter database set linger to 0
2025-02-25 15:46:02.810 ^
2025-02-25 15:46:02.821 """
2025-02-25 15:46:02.832 for x in sql.split('^'):
2025-02-25 15:46:02.840 if (s := x.strip()):
2025-02-25 15:46:02.847 con_a.execute_immediate(s)
2025-02-25 15:46:02.853 con_a.commit()
2025-02-25 15:46:02.859
2025-02-25 15:46:02.870 # ..................................................
2025-02-25 15:46:02.877
2025-02-25 15:46:02.885 sql = f"""
2025-02-25 15:46:02.892 create procedure sp_b (a_who varchar(31)) returns (o_info varchar(512)) as
2025-02-25 15:46:02.899 begin
2025-02-25 15:46:02.907 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 15:46:02.916 suspend;
2025-02-25 15:46:02.926 end
2025-02-25 15:46:02.933 ^
2025-02-25 15:46:02.945 grant execute on procedure sp_b to public
2025-02-25 15:46:02.956 ^
2025-02-25 15:46:02.965 alter database set linger to 0
2025-02-25 15:46:02.975 ^
2025-02-25 15:46:02.988 """
2025-02-25 15:46:02.998 for x in sql.split('^'):
2025-02-25 15:46:03.008 if (s := x.strip()):
2025-02-25 15:46:03.016 con_b.execute_immediate(s)
2025-02-25 15:46:03.024 con_b.commit()
2025-02-25 15:46:03.030
2025-02-25 15:46:03.037 # ..................................................
2025-02-25 15:46:03.044
2025-02-25 15:46:03.052 sql = f"""
2025-02-25 15:46:03.061 create procedure sp_c returns (o_info varchar(512)) as
2025-02-25 15:46:03.071 begin
2025-02-25 15:46:03.085 o_info = lower(current_user);
2025-02-25 15:46:03.095 -- o_info = lower(rdb$get_context('SYSTEM', 'DB_NAME')) || ':' || lower(current_user);
2025-02-25 15:46:03.103 suspend;
2025-02-25 15:46:03.109 end
2025-02-25 15:46:03.114 ^
2025-02-25 15:46:03.123 grant execute on procedure sp_c to public
2025-02-25 15:46:03.137 ^
2025-02-25 15:46:03.146 alter database set linger to 0
2025-02-25 15:46:03.155 ^
2025-02-25 15:46:03.162 """
2025-02-25 15:46:03.170 for x in sql.split('^'):
2025-02-25 15:46:03.184 if (s := x.strip()):
2025-02-25 15:46:03.196 con_c.execute_immediate(s)
2025-02-25 15:46:03.206 con_c.commit()
2025-02-25 15:46:03.218
2025-02-25 15:46:03.229 ############################################
2025-02-25 15:46:03.238 ###   E N C R Y P T    D A T A B A S E   ###
2025-02-25 15:46:03.247 ############################################
2025-02-25 15:46:03.258 >           run_encr_decr(act_c, 'encrypt', MAX_WAITING_ENCR_FINISH, capsys)
2025-02-25 15:46:03.266
2025-02-25 15:46:03.275 tests/bugs/gh_8429_test.py:272:
2025-02-25 15:46:03.284 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-02-25 15:46:03.292
2025-02-25 15:46:03.300 act = <firebird.qa.plugin.Action object at [hex]>, mode = 'encrypt'
2025-02-25 15:46:03.307 max_wait_encr_thread_finish = 10000
2025-02-25 15:46:03.314 capsys = <_pytest.capture.CaptureFixture object at [hex]>
2025-02-25 15:46:03.323
2025-02-25 15:46:03.334 def run_encr_decr(act: Action, mode, max_wait_encr_thread_finish, capsys):
2025-02-25 15:46:03.343 if mode == 'encrypt':
2025-02-25 15:46:03.351 # See letter from Alex, 15.12.2023 16:16 demo-plugin can not transfer named key over network.
2025-02-25 15:46:03.358 # Because of that, we have to use 'ALTER DATABASE ENCRYPT WITH <plugin>'  _WITHOUT_ adding 'key "{ENCRYPTION_KEY}"'.
2025-02-25 15:46:03.364 # ::: NB ::: One need to be sure that $FB_HOME/plugins.conf contains following lines:
2025-02-25 15:46:03.378 # Plugin = KH2 {
2025-02-25 15:46:03.386 #     Module = $(dir_plugins)/fbSampleKeyHolder
2025-02-25 15:46:03.392 #     RegisterName = fbSampleKeyHolder
2025-02-25 15:46:03.397 #     Config = KH2
2025-02-25 15:46:03.403 # }
2025-02-25 15:46:03.411 #  Config = KH2 {
2025-02-25 15:46:03.424 #     Auto = false
2025-02-25 15:46:03.438 # }
2025-02-25 15:46:03.448 # Otherwise error will raise:
2025-02-25 15:46:03.456 # unsuccessful metadata update
2025-02-25 15:46:03.466 # -ALTER DATABASE failed
2025-02-25 15:46:03.480 # -Missing database encryption key for your attachment
2025-02-25 15:46:03.491 # -Plugin fbSampleDbCrypt:
2025-02-25 15:46:03.502 # -Crypt key not set
2025-02-25 15:46:03.516 #
2025-02-25 15:46:03.526 alter_db_sttm = f'alter database encrypt with "{ENCRYPTION_PLUGIN}"' # <<< ::: NB ::: DO NOT add '... key "{ENCRYPTION_KEY}"' here!
2025-02-25 15:46:03.539 wait_for_state = 'Database encrypted'
2025-02-25 15:46:03.549 elif mode == 'decrypt':
2025-02-25 15:46:03.556 alter_db_sttm = 'alter database decrypt'
2025-02-25 15:46:03.564 wait_for_state = 'Database not encrypted'
2025-02-25 15:46:03.570
2025-02-25 15:46:03.577
2025-02-25 15:46:03.583 e_thread_finished = False
2025-02-25 15:46:03.589
2025-02-25 15:46:03.596 # 0 = non crypted;
2025-02-25 15:46:03.603 # 1 = has been encrypted;
2025-02-25 15:46:03.610 # 2 = is DEcrypting;
2025-02-25 15:46:03.619 # 3 = is Encrypting;
2025-02-25 15:46:03.631 #
2025-02-25 15:46:03.640 REQUIRED_CRYPT_STATE = 1 if mode == 'encrypt' else 0
2025-02-25 15:46:03.649 current_crypt_state = -1
2025-02-25 15:46:03.655 d1 = py_dt.timedelta(0)
2025-02-25 15:46:03.661 >       with act.db.connect() as con:
2025-02-25 15:46:03.667
2025-02-25 15:46:03.676 tests/bugs/gh_8429_test.py:147:
2025-02-25 15:46:03.689 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-02-25 15:46:03.698
2025-02-25 15:46:03.707 database = 'gh_8429_alias_c'
2025-02-25 15:46:03.719
2025-02-25 15:46:03.727 def connect(database: str, *, user: str=None, password: str=None, role: str=None,
2025-02-25 15:46:03.734 no_gc: bool=None, no_db_triggers: bool=None, dbkey_scope: DBKeyScope=None,
2025-02-25 15:46:03.741 crypt_callback: iCryptKeyCallbackImpl=None, charset: str=None,
2025-02-25 15:46:03.747 auth_plugin_list: str=None, session_time_zone: str=None) -> Connection:
2025-02-25 15:46:03.754 """Establishes a connection to the database.
2025-02-25 15:46:03.765
2025-02-25 15:46:03.777 Arguments:
2025-02-25 15:46:03.786 database: DSN or Database configuration name.
2025-02-25 15:46:03.801 user: User name.
2025-02-25 15:46:03.814 password: User password.
2025-02-25 15:46:03.825 role: User role.
2025-02-25 15:46:03.838 no_gc: Do not perform garbage collection for this connection.
2025-02-25 15:46:03.852 no_db_triggers: Do not execute database triggers for this connection.
2025-02-25 15:46:03.869 dbkey_scope: DBKEY scope override for connection.
2025-02-25 15:46:03.878 crypt_callback: Callback that provides encryption key for the database.
2025-02-25 15:46:03.887 charset: Character set for connection.
2025-02-25 15:46:03.895 auth_plugin_list: List of authentication plugins override
2025-02-25 15:46:03.910 session_time_zone: Session time zone [Firebird 4]
2025-02-25 15:46:03.920
2025-02-25 15:46:03.928 Hooks:
2025-02-25 15:46:03.936 Event `.ConnectionHook.ATTACH_REQUEST`: Executed after all parameters
2025-02-25 15:46:03.943 are preprocessed and before `Connection` is created. Hook
2025-02-25 15:46:03.952 must have signature::
2025-02-25 15:46:03.966
2025-02-25 15:46:03.978 hook_func(dsn: str, dpb: bytes) -> Optional[Connection]
2025-02-25 15:46:03.988
2025-02-25 15:46:03.997 Hook may return `Connection` instance or None.
2025-02-25 15:46:04.008 First instance returned by any hook will become the return value
2025-02-25 15:46:04.016 of this function and other hooks are not called.
2025-02-25 15:46:04.023
2025-02-25 15:46:04.030 Event `.ConnectionHook.ATTACHED`: Executed before `Connection` instance is
2025-02-25 15:46:04.045 returned. Hook must have signature::
2025-02-25 15:46:04.058
2025-02-25 15:46:04.065 hook_func(connection: Connection) -> None
2025-02-25 15:46:04.080
2025-02-25 15:46:04.095 Any value returned by hook is ignored.
2025-02-25 15:46:04.106 """
2025-02-25 15:46:04.115 db_config = driver_config.get_database(database)
2025-02-25 15:46:04.128 if db_config is None:
2025-02-25 15:46:04.139 db_config = driver_config.db_defaults
2025-02-25 15:46:04.147 else:
2025-02-25 15:46:04.154 database = db_config.database.value
2025-02-25 15:46:04.160 if db_config.server.value is None:
2025-02-25 15:46:04.167 srv_config = driver_config.server_defaults
2025-02-25 15:46:04.174 else:
2025-02-25 15:46:04.180 srv_config = driver_config.get_server(db_config.server.value)
2025-02-25 15:46:04.186 if srv_config is None:
2025-02-25 15:46:04.192 raise ValueError(f"Configuration for server '{db_config.server.value}' not found")
2025-02-25 15:46:04.199 if user is None:
2025-02-25 15:46:04.208 user = db_config.user.value
2025-02-25 15:46:04.222 if user is None:
2025-02-25 15:46:04.234 user = srv_config.user.value
2025-02-25 15:46:04.242 if password is None:
2025-02-25 15:46:04.250 password = db_config.password.value
2025-02-25 15:46:04.257 if password is None:
2025-02-25 15:46:04.264 password = srv_config.password.value
2025-02-25 15:46:04.271 if role is None:
2025-02-25 15:46:04.278 role = db_config.role.value
2025-02-25 15:46:04.286 if charset is None:
2025-02-25 15:46:04.300 charset = db_config.charset.value
2025-02-25 15:46:04.314 if charset:
2025-02-25 15:46:04.327 charset = charset.upper()
2025-02-25 15:46:04.338 if auth_plugin_list is None:
2025-02-25 15:46:04.347 auth_plugin_list = db_config.auth_plugin_list.value
2025-02-25 15:46:04.355 if session_time_zone is None:
2025-02-25 15:46:04.362 session_time_zone = db_config.session_time_zone.value
2025-02-25 15:46:04.376 dsn = _connect_helper(db_config.dsn.value, srv_config.host.value, srv_config.port.value,
2025-02-25 15:46:04.387 database, db_config.protocol.value)
2025-02-25 15:46:04.398 dpb = DPB(user=user, password=password, role=role, trusted_auth=db_config.trusted_auth.value,
2025-02-25 15:46:04.407 sql_dialect=db_config.sql_dialect.value, timeout=db_config.timeout.value,
2025-02-25 15:46:04.416 charset=charset, cache_size=db_config.cache_size.value,
2025-02-25 15:46:04.422 no_linger=db_config.no_linger.value, utf8filename=db_config.utf8filename.value,
2025-02-25 15:46:04.427 no_gc=no_gc, no_db_triggers=no_db_triggers, dbkey_scope=dbkey_scope,
2025-02-25 15:46:04.433 dummy_packet_interval=db_config.dummy_packet_interval.value,
2025-02-25 15:46:04.438 config=db_config.config.value, auth_plugin_list=auth_plugin_list,
2025-02-25 15:46:04.444 session_time_zone=session_time_zone, set_bind=db_config.set_bind.value,
2025-02-25 15:46:04.451 decfloat_round=db_config.decfloat_round.value,
2025-02-25 15:46:04.459 decfloat_traps=db_config.decfloat_traps.value,
2025-02-25 15:46:04.467 parallel_workers=db_config.parallel_workers.value)
2025-02-25 15:46:04.475 >       return __make_connection(False, dsn, db_config.utf8filename.value, dpb.get_buffer(),
2025-02-25 15:46:04.482 db_config.sql_dialect.value, charset, crypt_callback)
2025-02-25 15:46:04.495
2025-02-25 15:46:04.504 ../lib/python3.11/site-packages/firebird/driver/core.py:2149:
2025-02-25 15:46:04.513 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-02-25 15:46:04.520
2025-02-25 15:46:04.529 create = False, dsn = 'localhost/3720:gh_8429_alias_c', utf8filename = False
2025-02-25 15:46:04.540 dpb = b'\x01\x1c\x06SYSDBA\x1d\tmasterkey?\x04\x03\x00\x00\x00', sql_dialect = 3
2025-02-25 15:46:04.557 charset = None, crypt_callback = None
2025-02-25 15:46:04.573
2025-02-25 15:46:04.590 def __make_connection(create: bool, dsn: str, utf8filename: bool, dpb: bytes,
2025-02-25 15:46:04.601 sql_dialect: int, charset: str,
2025-02-25 15:46:04.611 crypt_callback: iCryptKeyCallbackImpl) -> Connection:
2025-02-25 15:46:04.620 with a.get_api().master.get_dispatcher() as provider:
2025-02-25 15:46:04.628 if crypt_callback is not None:
2025-02-25 15:46:04.637 provider.set_dbcrypt_callback(crypt_callback)
2025-02-25 15:46:04.645 if create:
2025-02-25 15:46:04.656 att = provider.create_database(dsn, dpb, 'utf-8' if utf8filename else FS_ENCODING)
2025-02-25 15:46:04.664 con = Connection(att, dsn, dpb, sql_dialect, charset)
2025-02-25 15:46:04.681 else:
2025-02-25 15:46:04.696 con = None
2025-02-25 15:46:04.709 for hook in get_callbacks(ConnectionHook.ATTACH_REQUEST, Connection):
2025-02-25 15:46:04.717 try:
2025-02-25 15:46:04.725 con = hook(dsn, dpb)
2025-02-25 15:46:04.733 except Exception as e:
2025-02-25 15:46:04.741 raise InterfaceError("Error in DATABASE_ATTACH_REQUEST hook.", *e.args) from e
2025-02-25 15:46:04.749 if con is not None:
2025-02-25 15:46:04.757 break
2025-02-25 15:46:04.764 if con is None:
2025-02-25 15:46:04.773 >                   att = provider.attach_database(dsn, dpb, 'utf-8' if utf8filename else FS_ENCODING)
2025-02-25 15:46:04.781
2025-02-25 15:46:04.794 ../lib/python3.11/site-packages/firebird/driver/core.py:2064:
2025-02-25 15:46:04.805 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-02-25 15:46:04.819
2025-02-25 15:46:04.831 self = <firebird.driver.interfaces.iProvider object at [hex]>
2025-02-25 15:46:04.846 filename = 'localhost/3720:gh_8429_alias_c'
2025-02-25 15:46:04.861 dpb = b'\x01\x1c\x06SYSDBA\x1d\tmasterkey?\x04\x03\x00\x00\x00'
2025-02-25 15:46:04.875 encoding = 'utf-8'
2025-02-25 15:46:04.889
2025-02-25 15:46:04.900 def attach_database(self, filename: str, dpb: Optional[bytes] = None, encoding: str = 'ascii') -> iAttachment:
2025-02-25 15:46:04.908 "Replaces `isc_attach_database()`"
2025-02-25 15:46:04.915 result = self.vtable.attachDatabase(self, self.status, filename.encode(encoding),
2025-02-25 15:46:04.922 0 if dpb is None else len(dpb), dpb)
2025-02-25 15:46:04.937 >       self._check()
2025-02-25 15:46:04.946
2025-02-25 15:46:04.953 ../lib/python3.11/site-packages/firebird/driver/interfaces.py:1295:
2025-02-25 15:46:04.960 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2025-02-25 15:46:04.967
2025-02-25 15:46:04.974 self = <firebird.driver.interfaces.iProvider object at [hex]>
2025-02-25 15:46:04.981
2025-02-25 15:46:04.987 def _check(self) -> None:
2025-02-25 15:46:04.993 state = self.status.get_state()
2025-02-25 15:46:05.001 if StateFlag.ERRORS in state:
2025-02-25 15:46:05.010 >           raise self.__report(DatabaseError, self.status.get_errors())
2025-02-25 15:46:05.024 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 15:46:05.033 E           -Database already opened with engine instance, incompatible with current
2025-02-25 15:46:05.046
2025-02-25 15:46:05.057 ../lib/python3.11/site-packages/firebird/driver/interfaces.py:113: DatabaseError
2025-02-25 15:46:05.065 ---------------------------- Captured stdout setup -----------------------------
2025-02-25 15:46:05.072 Creating db: localhost:/var/tmp/qa_2024/test_11574/test.fdb [page_size=None, sql_dialect=None, charset='NONE', user=SYSDBA, password=masterkey]
2025-02-25 15:46:05.079 CREATE user: TMP_8429_X PLUGIN: Srp
2025-02-25 15:46:05.086 CREATE user: TMP_8429_Y PLUGIN: Srp
2025-02-25 15:46:05.098 CREATE user: TMP_8429_Z PLUGIN: Srp
2025-02-25 15:46:05.108 --------------------------- Captured stdout teardown ---------------------------
2025-02-25 15:46:05.118 DROP user: TMP_8429_Z PLUGIN: Srp
2025-02-25 15:46:05.132 DROP user: TMP_8429_Y PLUGIN: Srp
2025-02-25 15:46:05.142 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/3720: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/3720: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.3189 2025.02.25 1a1a5 P P 4029 2845 2025.07.02 13:37:32.645 2025.07.02 13:37:36.674 2025.07.02 12:22:33.851 2025.07.02 12:22:36.696
2 4.0.6.3184 2025.02.24 9388c P F 845 1540 2025.02.25 13:50:07.002 2025.02.25 13:50:07.847 2025.02.25 12:31:07.519 2025.02.25 12:31:09.059

Elapsed time, ms. Chart for last 2 runs:

Last commits information (all timestamps in UTC):