2 @message |
assert
checked_mode: table, STDLOG: Records affected: 4
checked_mode: table, STDLOG: ID
checked_mode: table, STDLOG:
checked_mode: table, STDLOG: -5
checked_mode: table, STDLOG: Records affected: 1
checked_mode: table, STDLOG: OLD_ID OP SNAP_NO_RANK
checked_mode: table, STDLOG:
- checked_mode: table, STDLOG: 2 DEL 1
+ checked_mode: table, STDLOG: 2DEL 1
- checked_mode: table, STDLOG: 2 DEL 2
+ checked_mode: table, STDLOG: 2DEL 2
- checked_mode: table, STDLOG: 1 DEL 2
+ checked_mode: table, STDLOG: 1DEL 2
- checked_mode: table, STDLOG: 2 DEL 3
+ checked_mode: table, STDLOG: 2DEL 3
- checked_mode: table, STDLOG: 1 DEL 3
+ checked_mode: table, STDLOG: 1DEL 3
- checked_mode: table, STDLOG: 2 DEL 4
+ checked_mode: table, STDLOG: 2DEL 4
- checked_mode: table, STDLOG: 1 DEL 4
+ checked_mode: table, STDLOG: 1DEL 4
- checked_mode: table, STDLOG: -3 DEL 4
+ checked_mode: table, STDLOG: -3DEL 4
- checked_mode: table, STDLOG: -4 DEL 4
+ checked_mode: table, STDLOG: -4DEL 4
checked_mode: table, STDLOG: Records affected: 9
LOG DETAILS:
2025-07-02 06:07:42.982
2025-07-02 06:07:42.993 act = <firebird.qa.plugin.Action object at [hex]>
2025-07-02 06:07:43.002 fn_worker_sql = PosixPath('/var/tmp/qa_2024/test_12480/tmp_worker.sql')
2025-07-02 06:07:43.014 fn_worker_log = PosixPath('/var/tmp/qa_2024/test_12480/tmp_worker.log')
2025-07-02 06:07:43.026 fn_worker_err = PosixPath('/var/tmp/qa_2024/test_12480/tmp_worker.err')
2025-07-02 06:07:43.034 capsys = <_pytest.capture.CaptureFixture object at [hex]>
2025-07-02 06:07:43.041
2025-07-02 06:07:43.048 @pytest.mark.trace
2025-07-02 06:07:43.055 @pytest.mark.version('>=4.0')
2025-07-02 06:07:43.062 def test_1(act: Action, fn_worker_sql: Path, fn_worker_log: Path, fn_worker_err: Path, capsys):
2025-07-02 06:07:43.069 sql_init = (act.files_dir / 'read-consist-sttm-restart-DDL.sql').read_text()
2025-07-02 06:07:43.075
2025-07-02 06:07:43.082 for checked_mode in('table', 'view'):
2025-07-02 06:07:43.090 target_obj = 'test' if checked_mode == 'table' else 'v_test'
2025-07-02 06:07:43.102 SQL_TO_BE_RESTARTED = f'delete /* {SQL_TAG_THAT_WE_WAITING_FOR} */ from {target_obj} where id <= 2 order by id DESC rows 4'
2025-07-02 06:07:43.110 sql_addi = f'''
2025-07-02 06:07:43.117 set term ^;
2025-07-02 06:07:43.128 execute block as
2025-07-02 06:07:43.140 begin
2025-07-02 06:07:43.149 rdb$set_context('USER_SESSION', 'WHO', 'INIT_DATA');
2025-07-02 06:07:43.162 end
2025-07-02 06:07:43.172 ^
2025-07-02 06:07:43.181 set term ;^
2025-07-02 06:07:43.192 insert into {target_obj}(id, x)
2025-07-02 06:07:43.202 select row_number()over(),row_number()over()
2025-07-02 06:07:43.211 from rdb$types rows 5;
2025-07-02 06:07:43.219 commit;
2025-07-02 06:07:43.226 '''
2025-07-02 06:07:43.232
2025-07-02 06:07:43.238 act.isql(switches=['-q'], input = ''.join( (sql_init, sql_addi) ) )
2025-07-02 06:07:43.243 # ::: NOTE ::: We have to immediately quit if any error raised in prepare phase.
2025-07-02 06:07:43.249 # See also letter from dimitr, 01-feb-2022 14:46
2025-07-02 06:07:43.254 assert act.stderr == ''
2025-07-02 06:07:43.258 act.reset()
2025-07-02 06:07:43.263
2025-07-02 06:07:43.268 trace_cfg_items = [
2025-07-02 06:07:43.274 'time_threshold = 0',
2025-07-02 06:07:43.280 'log_errors = true',
2025-07-02 06:07:43.287 'log_statement_start = true',
2025-07-02 06:07:43.295 'log_statement_finish = true',
2025-07-02 06:07:43.302 ]
2025-07-02 06:07:43.313
2025-07-02 06:07:43.323 with act.trace(db_events = trace_cfg_items, encoding=locale.getpreferredencoding()):
2025-07-02 06:07:43.330
2025-07-02 06:07:43.340 with act.db.connect() as con_lock_1, act.db.connect() as con_lock_2, act.db.connect() as con_monitoring:
2025-07-02 06:07:43.350
2025-07-02 06:07:43.357 tpb_monitoring = tpb(isolation=Isolation.READ_COMMITTED_RECORD_VERSION, lock_timeout=0)
2025-07-02 06:07:43.362 tx_monitoring = con_monitoring.transaction_manager(tpb_monitoring)
2025-07-02 06:07:43.367 cur_monitoring = tx_monitoring.cursor()
2025-07-02 06:07:43.373
2025-07-02 06:07:43.378 for i,c in enumerate((con_lock_1,con_lock_2)):
2025-07-02 06:07:43.384 sttm = f"execute block as begin rdb$set_context('USER_SESSION', 'WHO', 'LOCKER #{i+1}'); end"
2025-07-02 06:07:43.389 c.execute_immediate(sttm)
2025-07-02 06:07:43.395
2025-07-02 06:07:43.401 #########################
2025-07-02 06:07:43.407 ### L O C K E R - 1 ###
2025-07-02 06:07:43.415 #########################
2025-07-02 06:07:43.420
2025-07-02 06:07:43.425 con_lock_1.execute_immediate( f'update {target_obj} set id=id where id=1' )
2025-07-02 06:07:43.430
2025-07-02 06:07:43.436 worker_sql = f'''
2025-07-02 06:07:43.445 set list on;
2025-07-02 06:07:43.458 set autoddl off;
2025-07-02 06:07:43.467 set term ^;
2025-07-02 06:07:43.480 execute block returns (whoami varchar(30)) as
2025-07-02 06:07:43.493 begin
2025-07-02 06:07:43.504 whoami = 'WORKER'; -- , ATT#' || current_connection;
2025-07-02 06:07:43.512 rdb$set_context('USER_SESSION','WHO', whoami);
2025-07-02 06:07:43.517 -- suspend;
2025-07-02 06:07:43.522 end
2025-07-02 06:07:43.526 ^
2025-07-02 06:07:43.531 set term ;^
2025-07-02 06:07:43.538 commit;
2025-07-02 06:07:43.544 SET KEEP_TRAN_PARAMS ON;
2025-07-02 06:07:43.550 set transaction read committed read consistency;
2025-07-02 06:07:43.562 set list off;
2025-07-02 06:07:43.572 set wng off;
2025-07-02 06:07:43.584
2025-07-02 06:07:43.594 set count on;
2025-07-02 06:07:43.601 -- this must hang because of locker-1:
2025-07-02 06:07:43.607
2025-07-02 06:07:43.612 {SQL_TO_BE_RESTARTED};
2025-07-02 06:07:43.617
2025-07-02 06:07:43.622 -- check results:
2025-07-02 06:07:43.629 -- ###############
2025-07-02 06:07:43.641 select id from {target_obj} order by id; -- one record must remain, with ID = -5
2025-07-02 06:07:43.649
2025-07-02 06:07:43.657 select v.old_id, v.op, v.snap_no_rank -- snap_no_rank must have four unique values: 1,2,3 and 4.
2025-07-02 06:07:43.665 from v_worker_log v
2025-07-02 06:07:43.672 where v.op = 'del';
2025-07-02 06:07:43.679
2025-07-02 06:07:43.685 --set width who 10;
2025-07-02 06:07:43.692 -- DO NOT check this! Values can differ here from one run to another!
2025-07-02 06:07:43.698 -- select id, trn, who, old_id, new_id, op, rec_vers, global_cn, snap_no from tlog_done order by id;
2025-07-02 06:07:43.703 rollback;
2025-07-02 06:07:43.707 '''
2025-07-02 06:07:43.712
2025-07-02 06:07:43.717 fn_worker_sql.write_text(worker_sql)
2025-07-02 06:07:43.722
2025-07-02 06:07:43.726 with fn_worker_log.open(mode='w') as hang_out, fn_worker_err.open(mode='w') as hang_err:
2025-07-02 06:07:43.731
2025-07-02 06:07:43.736 ############################################################################
2025-07-02 06:07:43.742 ### L A U N C H W O R K E R U S I N G I S Q L, A S Y N C. ###
2025-07-02 06:07:43.748 ############################################################################
2025-07-02 06:07:43.758 p_worker = subprocess.Popen([act.vars['isql'], '-i', str(fn_worker_sql),
2025-07-02 06:07:43.771 '-user', act.db.user,
2025-07-02 06:07:43.780 '-password', act.db.password,
2025-07-02 06:07:43.791 act.db.dsn
2025-07-02 06:07:43.799 ],
2025-07-02 06:07:43.808 stdout = hang_out,
2025-07-02 06:07:43.815 stderr = hang_err
2025-07-02 06:07:43.829 )
2025-07-02 06:07:43.839
2025-07-02 06:07:43.848 # NB: when ISQL will establish attach, first record that it must lock is ID = 2 -- see above SQL_TO_BE_RESTARTED
2025-07-02 06:07:43.856 # We must to ensure that this (worker) attachment has been really created and LOCKS this record:
2025-07-02 06:07:43.862 #
2025-07-02 06:07:43.871 wait_for_record_become_locked(tx_monitoring, cur_monitoring, f'update {target_obj} set id=id where id=2', SQL_TAG_THAT_WE_WAITING_FOR)
2025-07-02 06:07:43.883
2025-07-02 06:07:43.894 #########################
2025-07-02 06:07:43.903 ### L O C K E R - 2 ###
2025-07-02 06:07:43.910 #########################
2025-07-02 06:07:43.917
2025-07-02 06:07:43.924 # Change ID so that it **will* be included in the set of rows that must be affected by session-worker:
2025-07-02 06:07:43.930 con_lock_2.execute_immediate( f'update {target_obj} set id = -5 where abs(id) = 5;' )
2025-07-02 06:07:43.937 con_lock_2.commit()
2025-07-02 06:07:43.945 con_lock_2.execute_immediate( f'update {target_obj} set id = id where abs(id) = 5;' )
2025-07-02 06:07:43.952 con_lock_1.commit() # releases record with ID=1 ==> now it can be locked by worker.
2025-07-02 06:07:43.960 # We have to WAIT HERE until worker will actually 'catch' just released record with ID = 1.
2025-07-02 06:07:43.967 #
2025-07-02 06:07:43.975 wait_for_record_become_locked(tx_monitoring, cur_monitoring, f'update {target_obj} set id=id where id=1', SQL_TAG_THAT_WE_WAITING_FOR)
2025-07-02 06:07:43.982
2025-07-02 06:07:43.991
2025-07-02 06:07:44.004 # Change ID so that it **will* be included in the set of rows that must be affected by session-worker:
2025-07-02 06:07:44.014 con_lock_1.execute_immediate( f'update {target_obj} set id = -4 where abs(id) = 4;' )
2025-07-02 06:07:44.022 con_lock_1.commit()
2025-07-02 06:07:44.031 con_lock_1.execute_immediate( f'update {target_obj} set id = id where abs(id) = 4;' )
2025-07-02 06:07:44.043
2025-07-02 06:07:44.053 con_lock_2.commit() # releases record with ID = -5, but session-worker is waiting for record with ID = -4 (that was changed by locker-1).
2025-07-02 06:07:44.060
2025-07-02 06:07:44.067 # We have to WAIT HERE until worker will actually 'catch' just released record with ID = -5:
2025-07-02 06:07:44.074 #
2025-07-02 06:07:44.081 wait_for_record_become_locked(tx_monitoring, cur_monitoring, f'update {target_obj} set id=id where id = -5', SQL_TAG_THAT_WE_WAITING_FOR)
2025-07-02 06:07:44.087
2025-07-02 06:07:44.101 con_lock_2.execute_immediate( f'update {target_obj} set id = -3 where abs(id) = 3;' )
2025-07-02 06:07:44.112 con_lock_2.commit()
2025-07-02 06:07:44.124 con_lock_2.execute_immediate( f'update {target_obj} set id = id where abs(id) = 3;' )
2025-07-02 06:07:44.133
2025-07-02 06:07:44.145 con_lock_1.commit() # This releases row with ID=-4 but session-worker is waiting for ID = - 3 (changed by locker-2).
2025-07-02 06:07:44.156
2025-07-02 06:07:44.165 # We have to WAIT HERE until worker will actually 'catch' just released record with ID = -4:
2025-07-02 06:07:44.172 #
2025-07-02 06:07:44.179 wait_for_record_become_locked(tx_monitoring, cur_monitoring, f'update {target_obj} set id=id where id = -4', SQL_TAG_THAT_WE_WAITING_FOR)
2025-07-02 06:07:44.185
2025-07-02 06:07:44.192 # If we come here then it means that record with ID = -4 for sure is locked by WORKER.
2025-07-02 06:07:44.199
2025-07-02 06:07:44.211 con_lock_2.commit() # This releases row with ID=-3. No more locked rows so session-worker can finish its mission.
2025-07-02 06:07:44.222
2025-07-02 06:07:44.233 # Here we wait for ISQL complete its mission:
2025-07-02 06:07:44.244 p_worker.wait()
2025-07-02 06:07:44.255
2025-07-02 06:07:44.263 #< with act.db.connect() as con_lock_1, act.db.connect() as con_lock_2, act.db.connect() as con_monitoring
2025-07-02 06:07:44.269
2025-07-02 06:07:44.275 for g in (fn_worker_log, fn_worker_err):
2025-07-02 06:07:44.280 with g.open() as f:
2025-07-02 06:07:44.285 for line in f:
2025-07-02 06:07:44.290 if line.split():
2025-07-02 06:07:44.295 if g == fn_worker_log:
2025-07-02 06:07:44.299 print(f'checked_mode: {checked_mode}, STDLOG: {line}')
2025-07-02 06:07:44.305 else:
2025-07-02 06:07:44.310 print(f'UNEXPECTED STDERR {line}')
2025-07-02 06:07:44.322
2025-07-02 06:07:44.330
2025-07-02 06:07:44.337 expected_stdout_worker = f"""
2025-07-02 06:07:44.344 checked_mode: {checked_mode}, STDLOG: Records affected: 4
2025-07-02 06:07:44.349
2025-07-02 06:07:44.355 checked_mode: {checked_mode}, STDLOG: ID
2025-07-02 06:07:44.363 checked_mode: {checked_mode}, STDLOG: =======
2025-07-02 06:07:44.374 checked_mode: {checked_mode}, STDLOG: -5
2025-07-02 06:07:44.383 checked_mode: {checked_mode}, STDLOG: Records affected: 1
2025-07-02 06:07:44.390
2025-07-02 06:07:44.400 checked_mode: {checked_mode}, STDLOG: OLD_ID OP SNAP_NO_RANK
2025-07-02 06:07:44.408 checked_mode: {checked_mode}, STDLOG: ======= ====== =====================
2025-07-02 06:07:44.415 checked_mode: {checked_mode}, STDLOG: 2 DEL 1
2025-07-02 06:07:44.422 checked_mode: {checked_mode}, STDLOG: 2 DEL 2
2025-07-02 06:07:44.428 checked_mode: {checked_mode}, STDLOG: 1 DEL 2
2025-07-02 06:07:44.434 checked_mode: {checked_mode}, STDLOG: 2 DEL 3
2025-07-02 06:07:44.440 checked_mode: {checked_mode}, STDLOG: 1 DEL 3
2025-07-02 06:07:44.447 checked_mode: {checked_mode}, STDLOG: 2 DEL 4
2025-07-02 06:07:44.453 checked_mode: {checked_mode}, STDLOG: 1 DEL 4
2025-07-02 06:07:44.465 checked_mode: {checked_mode}, STDLOG: -3 DEL 4
2025-07-02 06:07:44.473 checked_mode: {checked_mode}, STDLOG: -4 DEL 4
2025-07-02 06:07:44.480 checked_mode: {checked_mode}, STDLOG: Records affected: 9
2025-07-02 06:07:44.486 """
2025-07-02 06:07:44.494
2025-07-02 06:07:44.501 act.expected_stdout = expected_stdout_worker
2025-07-02 06:07:44.507 act.stdout = capsys.readouterr().out
2025-07-02 06:07:44.513 > assert act.clean_stdout == act.clean_expected_stdout
2025-07-02 06:07:44.518 E assert
2025-07-02 06:07:44.526 E checked_mode: table, STDLOG: Records affected: 4
2025-07-02 06:07:44.538 E checked_mode: table, STDLOG: ID
2025-07-02 06:07:44.548 E checked_mode: table, STDLOG:
2025-07-02 06:07:44.557 E checked_mode: table, STDLOG: -5
2025-07-02 06:07:44.565 E checked_mode: table, STDLOG: Records affected: 1
2025-07-02 06:07:44.572 E checked_mode: table, STDLOG: OLD_ID OP SNAP_NO_RANK
2025-07-02 06:07:44.579 E checked_mode: table, STDLOG:
2025-07-02 06:07:44.585 E - checked_mode: table, STDLOG: 2 DEL 1
2025-07-02 06:07:44.605 E + checked_mode: table, STDLOG: 2DEL 1
2025-07-02 06:07:44.617 E - checked_mode: table, STDLOG: 2 DEL 2
2025-07-02 06:07:44.641 E + checked_mode: table, STDLOG: 2DEL 2
2025-07-02 06:07:44.655 E - checked_mode: table, STDLOG: 1 DEL 2
2025-07-02 06:07:44.678 E + checked_mode: table, STDLOG: 1DEL 2
2025-07-02 06:07:44.690 E - checked_mode: table, STDLOG: 2 DEL 3
2025-07-02 06:07:44.713 E + checked_mode: table, STDLOG: 2DEL 3
2025-07-02 06:07:44.723 E - checked_mode: table, STDLOG: 1 DEL 3
2025-07-02 06:07:44.743 E + checked_mode: table, STDLOG: 1DEL 3
2025-07-02 06:07:44.752 E - checked_mode: table, STDLOG: 2 DEL 4
2025-07-02 06:07:44.766 E + checked_mode: table, STDLOG: 2DEL 4
2025-07-02 06:07:44.773 E - checked_mode: table, STDLOG: 1 DEL 4
2025-07-02 06:07:44.787 E + checked_mode: table, STDLOG: 1DEL 4
2025-07-02 06:07:44.796 E - checked_mode: table, STDLOG: -3 DEL 4
2025-07-02 06:07:44.813 E + checked_mode: table, STDLOG: -3DEL 4
2025-07-02 06:07:44.820 E - checked_mode: table, STDLOG: -4 DEL 4
2025-07-02 06:07:44.833 E + checked_mode: table, STDLOG: -4DEL 4
2025-07-02 06:07:44.839 E checked_mode: table, STDLOG: Records affected: 9
2025-07-02 06:07:44.851
2025-07-02 06:07:44.862 tests/functional/transactions/test_read_consist_sttm_restart_on_delete_04.py:417: AssertionError
2025-07-02 06:07:44.874 ---------------------------- Captured stdout setup -----------------------------
2025-07-02 06:07:44.885 Creating db: localhost:/var/tmp/qa_2024/test_12480/test.fdb [page_size=None, sql_dialect=None, charset='NONE', user=SYSDBA, password=masterkey]
|
3 #text |
act = <firebird.qa.plugin.Action pytest object at [hex]>
fn_worker_sql = PosixPath('/var/tmp/qa_2024/test_12480/tmp_worker.sql')
fn_worker_log = PosixPath('/var/tmp/qa_2024/test_12480/tmp_worker.log')
fn_worker_err = PosixPath('/var/tmp/qa_2024/test_12480/tmp_worker.err')
capsys = <_pytest.capture.CaptureFixture pytest object at [hex]>
@pytest.mark.trace
@pytest.mark.version('>=4.0')
def test_1(act: Action, fn_worker_sql: Path, fn_worker_log: Path, fn_worker_err: Path, capsys):
sql_init = (act.files_dir / 'read-consist-sttm-restart-DDL.sql').read_text()
for checked_mode in('table', 'view'):
target_obj = 'test' if checked_mode == 'table' else 'v_test'
SQL_TO_BE_RESTARTED = f'delete /* {SQL_TAG_THAT_WE_WAITING_FOR} */ from {target_obj} where id <= 2 order by id DESC rows 4'
sql_addi = f'''
set term ^;
execute block as
begin
rdb$set_context('USER_SESSION', 'WHO', 'INIT_DATA');
end
^
set term ;^
insert into {target_obj}(id, x)
select row_number()over(),row_number()over()
from rdb$types rows 5;
commit;
'''
act.isql(switches=['-q'], input = ''.join( (sql_init, sql_addi) ) )
# ::: NOTE ::: We have to immediately quit if any error raised in prepare phase.
# See also letter from dimitr, 01-feb-2022 14:46
assert act.stderr == ''
act.reset()
trace_cfg_items = [
'time_threshold = 0',
'log_errors = true',
'log_statement_start = true',
'log_statement_finish = true',
]
with act.trace(db_events = trace_cfg_items, encoding=locale.getpreferredencoding()):
with act.db.connect() as con_lock_1, act.db.connect() as con_lock_2, act.db.connect() as con_monitoring:
tpb_monitoring = tpb(isolation=Isolation.READ_COMMITTED_RECORD_VERSION, lock_timeout=0)
tx_monitoring = con_monitoring.transaction_manager(tpb_monitoring)
cur_monitoring = tx_monitoring.cursor()
for i,c in enumerate((con_lock_1,con_lock_2)):
sttm = f"execute block as begin rdb$set_context('USER_SESSION', 'WHO', 'LOCKER #{i+1}'); end"
c.execute_immediate(sttm)
#########################
### L O C K E R - 1 ###
#########################
con_lock_1.execute_immediate( f'update {target_obj} set id=id where id=1' )
worker_sql = f'''
set list on;
set autoddl off;
set term ^;
execute block returns (whoami varchar(30)) as
begin
whoami = 'WORKER'; -- , ATT#' || current_connection;
rdb$set_context('USER_SESSION','WHO', whoami);
-- suspend;
end
^
set term ;^
commit;
SET KEEP_TRAN_PARAMS ON;
set transaction read committed read consistency;
set list off;
set wng off;
set count on;
-- this must hang because of locker-1:
{SQL_TO_BE_RESTARTED};
-- check results:
-- ###############
select id from {target_obj} order by id; -- one record must remain, with ID = -5
select v.old_id, v.op, v.snap_no_rank -- snap_no_rank must have four unique values: 1,2,3 and 4.
from v_worker_log v
where v.op = 'del';
--set width who 10;
-- DO NOT check this! Values can differ here from one run to another!
-- select id, trn, who, old_id, new_id, op, rec_vers, global_cn, snap_no from tlog_done order by id;
rollback;
'''
fn_worker_sql.write_text(worker_sql)
with fn_worker_log.open(mode='w') as hang_out, fn_worker_err.open(mode='w') as hang_err:
############################################################################
### L A U N C H W O R K E R U S I N G I S Q L, A S Y N C. ###
############################################################################
p_worker = subprocess.Popen([act.vars['isql'], '-i', str(fn_worker_sql),
'-user', act.db.user,
'-password', act.db.password,
act.db.dsn
],
stdout = hang_out,
stderr = hang_err
)
# NB: when ISQL will establish attach, first record that it must lock is ID = 2 -- see above SQL_TO_BE_RESTARTED
# We must to ensure that this (worker) attachment has been really created and LOCKS this record:
#
wait_for_record_become_locked(tx_monitoring, cur_monitoring, f'update {target_obj} set id=id where id=2', SQL_TAG_THAT_WE_WAITING_FOR)
#########################
### L O C K E R - 2 ###
#########################
# Change ID so that it **will* be included in the set of rows that must be affected by session-worker:
con_lock_2.execute_immediate( f'update {target_obj} set id = -5 where abs(id) = 5;' )
con_lock_2.commit()
con_lock_2.execute_immediate( f'update {target_obj} set id = id where abs(id) = 5;' )
con_lock_1.commit() # releases record with ID=1 ==> now it can be locked by worker.
# We have to WAIT HERE until worker will actually 'catch' just released record with ID = 1.
#
wait_for_record_become_locked(tx_monitoring, cur_monitoring, f'update {target_obj} set id=id where id=1', SQL_TAG_THAT_WE_WAITING_FOR)
# Change ID so that it **will* be included in the set of rows that must be affected by session-worker:
con_lock_1.execute_immediate( f'update {target_obj} set id = -4 where abs(id) = 4;' )
con_lock_1.commit()
con_lock_1.execute_immediate( f'update {target_obj} set id = id where abs(id) = 4;' )
con_lock_2.commit() # releases record with ID = -5, but session-worker is waiting for record with ID = -4 (that was changed by locker-1).
# We have to WAIT HERE until worker will actually 'catch' just released record with ID = -5:
#
wait_for_record_become_locked(tx_monitoring, cur_monitoring, f'update {target_obj} set id=id where id = -5', SQL_TAG_THAT_WE_WAITING_FOR)
con_lock_2.execute_immediate( f'update {target_obj} set id = -3 where abs(id) = 3;' )
con_lock_2.commit()
con_lock_2.execute_immediate( f'update {target_obj} set id = id where abs(id) = 3;' )
con_lock_1.commit() # This releases row with ID=-4 but session-worker is waiting for ID = - 3 (changed by locker-2).
# We have to WAIT HERE until worker will actually 'catch' just released record with ID = -4:
#
wait_for_record_become_locked(tx_monitoring, cur_monitoring, f'update {target_obj} set id=id where id = -4', SQL_TAG_THAT_WE_WAITING_FOR)
# If we come here then it means that record with ID = -4 for sure is locked by WORKER.
con_lock_2.commit() # This releases row with ID=-3. No more locked rows so session-worker can finish its mission.
# Here we wait for ISQL complete its mission:
p_worker.wait()
#< with act.db.connect() as con_lock_1, act.db.connect() as con_lock_2, act.db.connect() as con_monitoring
for g in (fn_worker_log, fn_worker_err):
with g.open() as f:
for line in f:
if line.split():
if g == fn_worker_log:
print(f'checked_mode: {checked_mode}, STDLOG: {line}')
else:
print(f'UNEXPECTED STDERR {line}')
expected_stdout_worker = f"""
checked_mode: {checked_mode}, STDLOG: Records affected: 4
checked_mode: {checked_mode}, STDLOG: ID
checked_mode: {checked_mode}, STDLOG: =======
checked_mode: {checked_mode}, STDLOG: -5
checked_mode: {checked_mode}, STDLOG: Records affected: 1
checked_mode: {checked_mode}, STDLOG: OLD_ID OP SNAP_NO_RANK
checked_mode: {checked_mode}, STDLOG: ======= ====== =====================
checked_mode: {checked_mode}, STDLOG: 2 DEL 1
checked_mode: {checked_mode}, STDLOG: 2 DEL 2
checked_mode: {checked_mode}, STDLOG: 1 DEL 2
checked_mode: {checked_mode}, STDLOG: 2 DEL 3
checked_mode: {checked_mode}, STDLOG: 1 DEL 3
checked_mode: {checked_mode}, STDLOG: 2 DEL 4
checked_mode: {checked_mode}, STDLOG: 1 DEL 4
checked_mode: {checked_mode}, STDLOG: -3 DEL 4
checked_mode: {checked_mode}, STDLOG: -4 DEL 4
checked_mode: {checked_mode}, STDLOG: Records affected: 9
"""
act.expected_stdout = expected_stdout_worker
act.stdout = capsys.readouterr().out
> assert act.clean_stdout == act.clean_expected_stdout
E assert
E checked_mode: table, STDLOG: Records affected: 4
E checked_mode: table, STDLOG: ID
E checked_mode: table, STDLOG:
E checked_mode: table, STDLOG: -5
E checked_mode: table, STDLOG: Records affected: 1
E checked_mode: table, STDLOG: OLD_ID OP SNAP_NO_RANK
E checked_mode: table, STDLOG:
E - checked_mode: table, STDLOG: 2 DEL 1
E + checked_mode: table, STDLOG: 2DEL 1
E - checked_mode: table, STDLOG: 2 DEL 2
E + checked_mode: table, STDLOG: 2DEL 2
E - checked_mode: table, STDLOG: 1 DEL 2
E + checked_mode: table, STDLOG: 1DEL 2
E - checked_mode: table, STDLOG: 2 DEL 3
E + checked_mode: table, STDLOG: 2DEL 3
E - checked_mode: table, STDLOG: 1 DEL 3
E + checked_mode: table, STDLOG: 1DEL 3
E - checked_mode: table, STDLOG: 2 DEL 4
E + checked_mode: table, STDLOG: 2DEL 4
E - checked_mode: table, STDLOG: 1 DEL 4
E + checked_mode: table, STDLOG: 1DEL 4
E - checked_mode: table, STDLOG: -3 DEL 4
E + checked_mode: table, STDLOG: -3DEL 4
E - checked_mode: table, STDLOG: -4 DEL 4
E + checked_mode: table, STDLOG: -4DEL 4
E checked_mode: table, STDLOG: Records affected: 9
tests/functional/transactions/test_read_consist_sttm_restart_on_delete_04.py:417: AssertionError
|