mirror of
https://github.com/FirebirdSQL/firebird-qa.git
synced 2025-01-22 13:33:07 +01:00
Added/Updated tests\bugs\core_6458_test.py: 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 can raises when Python runs garbage collection.
This commit is contained in:
parent
902f10a4fa
commit
bdce103159
@ -21,6 +21,8 @@ DESCRIPTION:
|
||||
* STDERR -- must contain (at least) two phrases:
|
||||
1. Statement failed, SQLSTATE = HY008
|
||||
2. operation was cancelled
|
||||
FBTEST: bugs.core_6458
|
||||
NOTES:
|
||||
|
||||
::: NB :::
|
||||
Windows only: subprocess.Popen() must have argument: creationflags = subprocess.CREATE_NEW_PROCESS_GROUP
|
||||
@ -32,8 +34,12 @@ DESCRIPTION:
|
||||
Confirmed bug on 4.0.0.2307: query could NOT be interrupted and we had to wait until it completed.
|
||||
Checked on 4.0.0.2324 (SS/CS): works OK, query can be interrupted via sending Ctrl-C signal.
|
||||
|
||||
JIRA: CORE-6458
|
||||
FBTEST: bugs.core_6458
|
||||
[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 re
|
||||
@ -100,14 +106,22 @@ def test_1(act: Action, heavy_script: Path, heavy_stdout: Path, heavy_stderr: Pa
|
||||
tx_watcher = con_watcher.transaction_manager(custom_tpb)
|
||||
cur_watcher = tx_watcher.cursor()
|
||||
|
||||
ps, rs = None, None
|
||||
try:
|
||||
ps = cur_watcher.prepare(chk_mon_sql)
|
||||
|
||||
i = 0
|
||||
da = dt.now()
|
||||
while True:
|
||||
cur_watcher.execute(ps, (p_heavy_sql.pid, HEAVY_TAG,) )
|
||||
# ::: 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, (p_heavy_sql.pid, HEAVY_TAG,) )
|
||||
mon_result = -1
|
||||
for r in cur_watcher:
|
||||
for r in rs:
|
||||
mon_result = r[0]
|
||||
|
||||
tx_watcher.commit()
|
||||
@ -118,11 +132,19 @@ def test_1(act: Action, heavy_script: Path, heavy_stdout: Path, heavy_stderr: Pa
|
||||
break
|
||||
elif diff_ms > MAX_WAIT_FOR_ISQL_PID_APPEARS_MS:
|
||||
break
|
||||
|
||||
time.sleep(0.1)
|
||||
|
||||
except DatabaseError as e:
|
||||
print( e.__str__() )
|
||||
print(e.gds_codes)
|
||||
finally:
|
||||
if rs:
|
||||
rs.close() # <<< EXPLICITLY CLOSING CURSOR RESULTS
|
||||
if ps:
|
||||
ps.free()
|
||||
|
||||
|
||||
|
||||
assert found_in_mon_tables, f'Could not find attachment in mon$ tables for {MAX_WAIT_FOR_ISQL_PID_APPEARS_MS} ms.'
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user