mirror of
https://github.com/FirebirdSQL/firebird-qa.git
synced 2025-01-22 13:33:07 +01:00
Added/Updated tests\bugs\gh_7200_test.py: added comments
This commit is contained in:
parent
7740052e00
commit
1fc6791847
@ -37,6 +37,13 @@ NOTES:
|
|||||||
Increased number of inserted rows (from 100'000 to 200'000) and indexed column width (from 700 to 800).
|
Increased number of inserted rows (from 100'000 to 200'000) and indexed column width (from 700 to 800).
|
||||||
Otherwise test could fail because encryption thread completes too fast (encountered under Linux).
|
Otherwise test could fail because encryption thread completes too fast (encountered under Linux).
|
||||||
Loop that checks for appearance of encryption state = 3 must have delay much less than one second (changed it from 1 to 0.1).
|
Loop that checks for appearance of encryption state = 3 must have delay much less than one second (changed it from 1 to 0.1).
|
||||||
|
|
||||||
|
[18.01.2025] pzotov
|
||||||
|
Resultset of cursor that executes using instance of selectable PreparedStatement must be stored
|
||||||
|
in some variable in order to have ability close it EXPLICITLY (before PS will be freed).
|
||||||
|
Otherwise access violation raises during Python GC and pytest hangs at final point (does not return control to OS).
|
||||||
|
This occurs at least for: Python 3.11.2 / pytest: 7.4.4 / firebird.driver: 1.10.6 / Firebird.Qa: 0.19.3
|
||||||
|
The reason of that was explained by Vlad, 26.10.24 17:42 ("oddities when use instances of selective statements").
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import datetime as py_dt
|
import datetime as py_dt
|
||||||
@ -128,34 +135,48 @@ def test_1(act: Action, act_tmp: Action, tmp_sql: Path, tmp_log: Path, capsys):
|
|||||||
|
|
||||||
encryption_started = False
|
encryption_started = False
|
||||||
with act_tmp.db.connect() as con_watcher:
|
with act_tmp.db.connect() as con_watcher:
|
||||||
|
|
||||||
|
ps, rs = None, None
|
||||||
|
try:
|
||||||
|
custom_tpb = tpb(isolation = Isolation.SNAPSHOT, lock_timeout = -1)
|
||||||
|
tx_watcher = con_watcher.transaction_manager(custom_tpb)
|
||||||
|
cur_watcher = tx_watcher.cursor()
|
||||||
|
|
||||||
custom_tpb = tpb(isolation = Isolation.SNAPSHOT, lock_timeout = -1)
|
# 0 = non-encrypted; 1 = encrypted; 2 = is DEcrypting; 3 - is Encrypting
|
||||||
tx_watcher = con_watcher.transaction_manager(custom_tpb)
|
ps = cur_watcher.prepare('select mon$crypt_state from mon$database')
|
||||||
cur_watcher = tx_watcher.cursor()
|
|
||||||
|
|
||||||
# 0 = non-encrypted; 1 = encrypted; 2 = is DEcrypting; 3 - is Encrypting
|
i = 0
|
||||||
ps = cur_watcher.prepare('select mon$crypt_state from mon$database')
|
da = dt.now()
|
||||||
|
while True:
|
||||||
|
# ::: NB ::: 'ps' returns data, i.e. this is SELECTABLE expression.
|
||||||
|
# We have to store result of cur.execute(<psInstance>) in order to
|
||||||
|
# close it explicitly.
|
||||||
|
# Otherwise AV can occur during Python garbage collection and this
|
||||||
|
# causes pytest to hang on its final point.
|
||||||
|
# Explained by hvlad, email 26.10.24 17:42
|
||||||
|
rs = cur_watcher.execute(ps)
|
||||||
|
for r in rs:
|
||||||
|
db_crypt_state = r[0]
|
||||||
|
|
||||||
i = 0
|
tx_watcher.commit()
|
||||||
da = dt.now()
|
db = dt.now()
|
||||||
while True:
|
diff_ms = (db-da).seconds*1000 + (db-da).microseconds//1000
|
||||||
cur_watcher.execute(ps)
|
if db_crypt_state == IS_ENCRYPTING_STATE:
|
||||||
for r in cur_watcher:
|
encryption_started = True
|
||||||
db_crypt_state = r[0]
|
cur_watcher.call_procedure('sp_debug', ('encryption_started',))
|
||||||
|
break
|
||||||
|
elif diff_ms > MAX_WAIT_FOR_ENCRYPTION_START_MS:
|
||||||
|
break
|
||||||
|
time.sleep(0.1)
|
||||||
|
|
||||||
tx_watcher.commit()
|
except DatabaseError as e:
|
||||||
db = dt.now()
|
print( e.__str__() )
|
||||||
diff_ms = (db-da).seconds*1000 + (db-da).microseconds//1000
|
print(e.gds_codes)
|
||||||
if db_crypt_state == IS_ENCRYPTING_STATE:
|
finally:
|
||||||
encryption_started = True
|
if rs:
|
||||||
cur_watcher.call_procedure('sp_debug', ('encryption_started',))
|
rs.close() # <<< EXPLICITLY CLOSING CURSOR RESULTS
|
||||||
break
|
if ps:
|
||||||
elif diff_ms > MAX_WAIT_FOR_ENCRYPTION_START_MS:
|
ps.free()
|
||||||
break
|
|
||||||
|
|
||||||
time.sleep(0.1)
|
|
||||||
|
|
||||||
ps.free()
|
|
||||||
|
|
||||||
assert encryption_started, f'Could not find start of encryption process for {MAX_WAIT_FOR_ENCRYPTION_START_MS} ms.'
|
assert encryption_started, f'Could not find start of encryption process for {MAX_WAIT_FOR_ENCRYPTION_START_MS} ms.'
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user