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-01 06:04:56.991
2025-07-01 06:04:57.004 act = <firebird.qa.plugin.Action object at [hex]>
2025-07-01 06:04:57.015 fn_worker_sql = PosixPath('/var/tmp/qa_2024/test_12479/tmp_worker.sql')
2025-07-01 06:04:57.023 fn_worker_log = PosixPath('/var/tmp/qa_2024/test_12479/tmp_worker.log')
2025-07-01 06:04:57.029 fn_worker_err = PosixPath('/var/tmp/qa_2024/test_12479/tmp_worker.err')
2025-07-01 06:04:57.035 capsys = <_pytest.capture.CaptureFixture object at [hex]>
2025-07-01 06:04:57.040
2025-07-01 06:04:57.047 @pytest.mark.trace
2025-07-01 06:04:57.057 @pytest.mark.version('>=4.0')
2025-07-01 06:04:57.069 def test_1(act: Action, fn_worker_sql: Path, fn_worker_log: Path, fn_worker_err: Path, capsys):
2025-07-01 06:04:57.079 sql_init = (act.files_dir / 'read-consist-sttm-restart-DDL.sql').read_text()
2025-07-01 06:04:57.087
2025-07-01 06:04:57.101 for checked_mode in('table', 'view'):
2025-07-01 06:04:57.112 target_obj = 'test' if checked_mode == 'table' else 'v_test'
2025-07-01 06:04:57.126 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-01 06:04:57.137 sql_addi = f'''
2025-07-01 06:04:57.151 set term ^;
2025-07-01 06:04:57.164 execute block as
2025-07-01 06:04:57.177 begin
2025-07-01 06:04:57.190 rdb$set_context('USER_SESSION', 'WHO', 'INIT_DATA');
2025-07-01 06:04:57.201 end
2025-07-01 06:04:57.208 ^
2025-07-01 06:04:57.215 set term ;^
2025-07-01 06:04:57.223 insert into {target_obj}(id, x)
2025-07-01 06:04:57.234 select row_number()over(),row_number()over()
2025-07-01 06:04:57.243 from rdb$types rows 5;
2025-07-01 06:04:57.251 commit;
2025-07-01 06:04:57.257 '''
2025-07-01 06:04:57.262
2025-07-01 06:04:57.272 act.isql(switches=['-q'], input = ''.join( (sql_init, sql_addi) ) )
2025-07-01 06:04:57.280 # ::: NOTE ::: We have to immediately quit if any error raised in prepare phase.
2025-07-01 06:04:57.286 # See also letter from dimitr, 01-feb-2022 14:46
2025-07-01 06:04:57.297 assert act.stderr == ''
2025-07-01 06:04:57.308 act.reset()
2025-07-01 06:04:57.320
2025-07-01 06:04:57.329 trace_cfg_items = [
2025-07-01 06:04:57.340 'time_threshold = 0',
2025-07-01 06:04:57.353 'log_errors = true',
2025-07-01 06:04:57.365 'log_statement_start = true',
2025-07-01 06:04:57.378 'log_statement_finish = true',
2025-07-01 06:04:57.389 ]
2025-07-01 06:04:57.398
2025-07-01 06:04:57.408 with act.trace(db_events = trace_cfg_items, encoding=locale.getpreferredencoding()):
2025-07-01 06:04:57.415
2025-07-01 06:04:57.423 with act.db.connect() as con_lock_1, act.db.connect() as con_lock_2, act.db.connect() as con_monitoring:
2025-07-01 06:04:57.430
2025-07-01 06:04:57.437 tpb_monitoring = tpb(isolation=Isolation.READ_COMMITTED_RECORD_VERSION, lock_timeout=0)
2025-07-01 06:04:57.444 tx_monitoring = con_monitoring.transaction_manager(tpb_monitoring)
2025-07-01 06:04:57.450 cur_monitoring = tx_monitoring.cursor()
2025-07-01 06:04:57.457
2025-07-01 06:04:57.463 for i,c in enumerate((con_lock_1,con_lock_2)):
2025-07-01 06:04:57.469 sttm = f"execute block as begin rdb$set_context('USER_SESSION', 'WHO', 'LOCKER #{i+1}'); end"
2025-07-01 06:04:57.475 c.execute_immediate(sttm)
2025-07-01 06:04:57.481
2025-07-01 06:04:57.486 #########################
2025-07-01 06:04:57.492 ### L O C K E R - 1 ###
2025-07-01 06:04:57.499 #########################
2025-07-01 06:04:57.505
2025-07-01 06:04:57.511 con_lock_1.execute_immediate( f'update {target_obj} set id=id where id=1' )
2025-07-01 06:04:57.516
2025-07-01 06:04:57.522 worker_sql = f'''
2025-07-01 06:04:57.531 set list on;
2025-07-01 06:04:57.543 set autoddl off;
2025-07-01 06:04:57.550 set term ^;
2025-07-01 06:04:57.557 execute block returns (whoami varchar(30)) as
2025-07-01 06:04:57.563 begin
2025-07-01 06:04:57.570 whoami = 'WORKER'; -- , ATT#' || current_connection;
2025-07-01 06:04:57.579 rdb$set_context('USER_SESSION','WHO', whoami);
2025-07-01 06:04:57.590 -- suspend;
2025-07-01 06:04:57.599 end
2025-07-01 06:04:57.606 ^
2025-07-01 06:04:57.612 set term ;^
2025-07-01 06:04:57.618 commit;
2025-07-01 06:04:57.625 SET KEEP_TRAN_PARAMS ON;
2025-07-01 06:04:57.632 set transaction read committed read consistency;
2025-07-01 06:04:57.637 set list off;
2025-07-01 06:04:57.642 set wng off;
2025-07-01 06:04:57.652
2025-07-01 06:04:57.661 set count on;
2025-07-01 06:04:57.668 -- this must hang because of locker-1:
2025-07-01 06:04:57.675
2025-07-01 06:04:57.681 {SQL_TO_BE_RESTARTED};
2025-07-01 06:04:57.686
2025-07-01 06:04:57.693 -- check results:
2025-07-01 06:04:57.698 -- ###############
2025-07-01 06:04:57.706 select id from {target_obj} order by id; -- one record must remain, with ID = -5
2025-07-01 06:04:57.711
2025-07-01 06:04:57.718 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-01 06:04:57.723 from v_worker_log v
2025-07-01 06:04:57.732 where v.op = 'del';
2025-07-01 06:04:57.745
2025-07-01 06:04:57.755 --set width who 10;
2025-07-01 06:04:57.763 -- DO NOT check this! Values can differ here from one run to another!
2025-07-01 06:04:57.770 -- select id, trn, who, old_id, new_id, op, rec_vers, global_cn, snap_no from tlog_done order by id;
2025-07-01 06:04:57.777 rollback;
2025-07-01 06:04:57.783 '''
2025-07-01 06:04:57.789
2025-07-01 06:04:57.795 fn_worker_sql.write_text(worker_sql)
2025-07-01 06:04:57.800
2025-07-01 06:04:57.806 with fn_worker_log.open(mode='w') as hang_out, fn_worker_err.open(mode='w') as hang_err:
2025-07-01 06:04:57.816
2025-07-01 06:04:57.827 ############################################################################
2025-07-01 06:04:57.835 ### 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-01 06:04:57.842 ############################################################################
2025-07-01 06:04:57.852 p_worker = subprocess.Popen([act.vars['isql'], '-i', str(fn_worker_sql),
2025-07-01 06:04:57.864 '-user', act.db.user,
2025-07-01 06:04:57.873 '-password', act.db.password,
2025-07-01 06:04:57.880 act.db.dsn
2025-07-01 06:04:57.886 ],
2025-07-01 06:04:57.898 stdout = hang_out,
2025-07-01 06:04:57.906 stderr = hang_err
2025-07-01 06:04:57.917 )
2025-07-01 06:04:57.926
2025-07-01 06:04:57.936 # NB: when ISQL will establish attach, first record that it must lock is ID = 2 -- see above SQL_TO_BE_RESTARTED
2025-07-01 06:04:57.946 # We must to ensure that this (worker) attachment has been really created and LOCKS this record:
2025-07-01 06:04:57.958 #
2025-07-01 06:04:57.967 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-01 06:04:57.980
2025-07-01 06:04:57.992 #########################
2025-07-01 06:04:58.002 ### L O C K E R - 2 ###
2025-07-01 06:04:58.010 #########################
2025-07-01 06:04:58.021
2025-07-01 06:04:58.031 # Change ID so that it **will* be included in the set of rows that must be affected by session-worker:
2025-07-01 06:04:58.039 con_lock_2.execute_immediate( f'update {target_obj} set id = -5 where abs(id) = 5;' )
2025-07-01 06:04:58.046 con_lock_2.commit()
2025-07-01 06:04:58.055 con_lock_2.execute_immediate( f'update {target_obj} set id = id where abs(id) = 5;' )
2025-07-01 06:04:58.066 con_lock_1.commit() # releases record with ID=1 ==> now it can be locked by worker.
2025-07-01 06:04:58.076 # We have to WAIT HERE until worker will actually 'catch' just released record with ID = 1.
2025-07-01 06:04:58.088 #
2025-07-01 06:04:58.097 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-01 06:04:58.103
2025-07-01 06:04:58.114
2025-07-01 06:04:58.125 # Change ID so that it **will* be included in the set of rows that must be affected by session-worker:
2025-07-01 06:04:58.133 con_lock_1.execute_immediate( f'update {target_obj} set id = -4 where abs(id) = 4;' )
2025-07-01 06:04:58.139 con_lock_1.commit()
2025-07-01 06:04:58.145 con_lock_1.execute_immediate( f'update {target_obj} set id = id where abs(id) = 4;' )
2025-07-01 06:04:58.151
2025-07-01 06:04:58.159 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-01 06:04:58.166
2025-07-01 06:04:58.180 # We have to WAIT HERE until worker will actually 'catch' just released record with ID = -5:
2025-07-01 06:04:58.186 #
2025-07-01 06:04:58.194 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-01 06:04:58.205
2025-07-01 06:04:58.215 con_lock_2.execute_immediate( f'update {target_obj} set id = -3 where abs(id) = 3;' )
2025-07-01 06:04:58.223 con_lock_2.commit()
2025-07-01 06:04:58.229 con_lock_2.execute_immediate( f'update {target_obj} set id = id where abs(id) = 3;' )
2025-07-01 06:04:58.234
2025-07-01 06:04:58.240 con_lock_1.commit() # This releases row with ID=-4 but session-worker is waiting for ID = - 3 (changed by locker-2).
2025-07-01 06:04:58.246
2025-07-01 06:04:58.252 # We have to WAIT HERE until worker will actually 'catch' just released record with ID = -4:
2025-07-01 06:04:58.257 #
2025-07-01 06:04:58.264 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-01 06:04:58.271
2025-07-01 06:04:58.281 # If we come here then it means that record with ID = -4 for sure is locked by WORKER.
2025-07-01 06:04:58.292
2025-07-01 06:04:58.303 con_lock_2.commit() # This releases row with ID=-3. No more locked rows so session-worker can finish its mission.
2025-07-01 06:04:58.310
2025-07-01 06:04:58.321 # Here we wait for ISQL complete its mission:
2025-07-01 06:04:58.333 p_worker.wait()
2025-07-01 06:04:58.343
2025-07-01 06:04:58.352 #< with act.db.connect() as con_lock_1, act.db.connect() as con_lock_2, act.db.connect() as con_monitoring
2025-07-01 06:04:58.358
2025-07-01 06:04:58.366 for g in (fn_worker_log, fn_worker_err):
2025-07-01 06:04:58.374 with g.open() as f:
2025-07-01 06:04:58.380 for line in f:
2025-07-01 06:04:58.386 if line.split():
2025-07-01 06:04:58.392 if g == fn_worker_log:
2025-07-01 06:04:58.399 print(f'checked_mode: {checked_mode}, STDLOG: {line}')
2025-07-01 06:04:58.409 else:
2025-07-01 06:04:58.419 print(f'UNEXPECTED STDERR {line}')
2025-07-01 06:04:58.427
2025-07-01 06:04:58.435
2025-07-01 06:04:58.441 expected_stdout_worker = f"""
2025-07-01 06:04:58.447 checked_mode: {checked_mode}, STDLOG: Records affected: 4
2025-07-01 06:04:58.452
2025-07-01 06:04:58.458 checked_mode: {checked_mode}, STDLOG: ID
2025-07-01 06:04:58.463 checked_mode: {checked_mode}, STDLOG: =======
2025-07-01 06:04:58.468 checked_mode: {checked_mode}, STDLOG: -5
2025-07-01 06:04:58.474 checked_mode: {checked_mode}, STDLOG: Records affected: 1
2025-07-01 06:04:58.484
2025-07-01 06:04:58.493 checked_mode: {checked_mode}, STDLOG: OLD_ID OP SNAP_NO_RANK
2025-07-01 06:04:58.501 checked_mode: {checked_mode}, STDLOG: ======= ====== =====================
2025-07-01 06:04:58.507 checked_mode: {checked_mode}, STDLOG: 2 DEL 1
2025-07-01 06:04:58.514 checked_mode: {checked_mode}, STDLOG: 2 DEL 2
2025-07-01 06:04:58.522 checked_mode: {checked_mode}, STDLOG: 1 DEL 2
2025-07-01 06:04:58.533 checked_mode: {checked_mode}, STDLOG: 2 DEL 3
2025-07-01 06:04:58.542 checked_mode: {checked_mode}, STDLOG: 1 DEL 3
2025-07-01 06:04:58.553 checked_mode: {checked_mode}, STDLOG: 2 DEL 4
2025-07-01 06:04:58.564 checked_mode: {checked_mode}, STDLOG: 1 DEL 4
2025-07-01 06:04:58.576 checked_mode: {checked_mode}, STDLOG: -3 DEL 4
2025-07-01 06:04:58.583 checked_mode: {checked_mode}, STDLOG: -4 DEL 4
2025-07-01 06:04:58.593 checked_mode: {checked_mode}, STDLOG: Records affected: 9
2025-07-01 06:04:58.600 """
2025-07-01 06:04:58.606
2025-07-01 06:04:58.613 act.expected_stdout = expected_stdout_worker
2025-07-01 06:04:58.620 act.stdout = capsys.readouterr().out
2025-07-01 06:04:58.627 > assert act.clean_stdout == act.clean_expected_stdout
2025-07-01 06:04:58.639 E assert
2025-07-01 06:04:58.650 E checked_mode: table, STDLOG: Records affected: 4
2025-07-01 06:04:58.661 E checked_mode: table, STDLOG: ID
2025-07-01 06:04:58.670 E checked_mode: table, STDLOG:
2025-07-01 06:04:58.677 E checked_mode: table, STDLOG: -5
2025-07-01 06:04:58.683 E checked_mode: table, STDLOG: Records affected: 1
2025-07-01 06:04:58.689 E checked_mode: table, STDLOG: OLD_ID OP SNAP_NO_RANK
2025-07-01 06:04:58.693 E checked_mode: table, STDLOG:
2025-07-01 06:04:58.699 E - checked_mode: table, STDLOG: 2 DEL 1
2025-07-01 06:04:58.711 E + checked_mode: table, STDLOG: 2DEL 1
2025-07-01 06:04:58.719 E - checked_mode: table, STDLOG: 2 DEL 2
2025-07-01 06:04:58.732 E + checked_mode: table, STDLOG: 2DEL 2
2025-07-01 06:04:58.739 E - checked_mode: table, STDLOG: 1 DEL 2
2025-07-01 06:04:58.752 E + checked_mode: table, STDLOG: 1DEL 2
2025-07-01 06:04:58.759 E - checked_mode: table, STDLOG: 2 DEL 3
2025-07-01 06:04:58.779 E + checked_mode: table, STDLOG: 2DEL 3
2025-07-01 06:04:58.789 E - checked_mode: table, STDLOG: 1 DEL 3
2025-07-01 06:04:58.811 E + checked_mode: table, STDLOG: 1DEL 3
2025-07-01 06:04:58.822 E - checked_mode: table, STDLOG: 2 DEL 4
2025-07-01 06:04:58.835 E + checked_mode: table, STDLOG: 2DEL 4
2025-07-01 06:04:58.840 E - checked_mode: table, STDLOG: 1 DEL 4
2025-07-01 06:04:58.852 E + checked_mode: table, STDLOG: 1DEL 4
2025-07-01 06:04:58.858 E - checked_mode: table, STDLOG: -3 DEL 4
2025-07-01 06:04:58.870 E + checked_mode: table, STDLOG: -3DEL 4
2025-07-01 06:04:58.876 E - checked_mode: table, STDLOG: -4 DEL 4
2025-07-01 06:04:58.887 E + checked_mode: table, STDLOG: -4DEL 4
2025-07-01 06:04:58.895 E checked_mode: table, STDLOG: Records affected: 9
2025-07-01 06:04:58.907
2025-07-01 06:04:58.917 tests/functional/transactions/test_read_consist_sttm_restart_on_delete_04.py:417: AssertionError
2025-07-01 06:04:58.928 ---------------------------- Captured stdout setup -----------------------------
2025-07-01 06:04:58.940 Creating db: localhost:/var/tmp/qa_2024/test_12479/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_12479/tmp_worker.sql')
fn_worker_log = PosixPath('/var/tmp/qa_2024/test_12479/tmp_worker.log')
fn_worker_err = PosixPath('/var/tmp/qa_2024/test_12479/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
|