Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sweep does not start if one of connects doing select * from ... where ... FOR UPDATE WITH LOCK without COMMIT or ROLLBACK [CORE3922] #4257

Closed
firebird-automations opened this issue Sep 11, 2012 · 5 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: @pavel-zotov

Attachments:
trace_no_sweep_starts_when_select_for_update_with_lock.zip

session #⁠1
#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠
C:\1INSTALL\FIREBIRD\Data>isql localhost:C:\1INSTALL\FIREBIRD\Data\t1.fdb -n
Database: localhost:C:\1INSTALL\FIREBIRD\Data\t1.fdb
SQL> show database;
Database: localhost:C:\1INSTALL\FIREBIRD\Data\t1.fdb
Owner: SYSDBA
PAGE_SIZE 4096
Number of DB pages allocated = 196
Sweep interval = 20000
Forced Writes are OFF
Transaction - oldest = 3
Transaction - oldest active = 4
Transaction - oldest snapshot = 4
Transaction - Next = 6
ODS = 11.2
Default Character set: NONE

recreate table tfix1(id int primary key, s01 varchar(1000));
recreate table tfix2(id int primary key, s01 varchar(1000));
recreate table tfix3(id int primary key, s01 varchar(1000));
commit;
insert into tfix1 values(-1,'tfix1');
insert into tfix2 values(-2,'tfix2');
insert into tfix3 values(-2,'tfix2');
commit;

set transaction read committed;
set term ^;
execute block as
declare n int = 200000;
declare k int;
begin
while (n>0) do begin
insert into tfix1(id,s01) values(:n, rpad('',1000,'x'));
insert into tfix2(id,s01) values(:n, rpad('',1000,'x'));
insert into tfix3(id,s01) values(:n, rpad('',1000,'x'));
n=n-1;
end
end^
set term ;^
-- here we must wait a few minutes until this EB is finished ...

session #⁠2
#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠
session #⁠2

C:\1INSTALL\FIREBIRD\Data>isql localhost:C:\1INSTALL\FIREBIRD\Data\t1.fdb -n
Database: localhost:C:\1INSTALL\FIREBIRD\Data\t1.fdb
commit;
set transaction read committed;
set term ^;
execute block as
declare n int = 21000;
declare k int;
begin
while (n>0) do begin
in autonomous transaction do select 1 from rdb$database into :k;
n=n-1;
end
end^
set term ;^
commit;
set list on;
select * from tfix1 where id<0 for update with lock;
set list off;
/*
after 1..2 seconds we will get:
ID -1
S01 tfix1
*/

session #⁠3
#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠
start trace with enabled log_sweep.

session #⁠1
#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠
SQL> rollback;
SQL> show database; -- this action finishes with COMMIT
Database: localhost:C:\1INSTALL\FIREBIRD\Data\t1.fdb
Owner: SYSDBA
PAGE_SIZE 4096
Number of DB pages allocated = 11810
Sweep interval = 20000
Forced Writes are OFF
Transaction - oldest = 5
Transaction - oldest active = 21009
Transaction - oldest snapshot = 6
Transaction - Next = 21011
ODS = 11.2
Default Character set: NONE
SQL> select 1 from rdb$database;

CONSTANT

============
1

-- sweep does NOT start here (no info about it in trace window)

session #⁠2
#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠#⁠
SQL> commit;
SQL> set list on;
SQL> select * from tfix1 where id<0 for update with lock; -- sweep starts only now

ID -1
S01 tfix1

SQL> set list off;

See firebird.log and trace in attach.

@firebird-automations
Copy link
Collaborator Author

Commented by: @pavel-zotov

SQL> show version;
ISQL Version: WI-V2.5.2.26536 Firebird 2.5
Server version:
Firebird/x86/Windows NT (access method), version "WI-V2.5.2.26536 Firebird 2.5"
Firebird/x86/Windows NT (remote server), version "WI-V2.5.2.26536 Firebird 2.5/tcp (balaha)/P12"
Firebird/x86/Windows NT (remote interface), version "WI-V2.5.2.26536 Firebird 2.5/tcp (balaha)/P12"
on disk structure version 11.2

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

Attachment: trace_no_sweep_starts_when_select_for_update_with_lock.zip [ 12208 ]

@firebird-automations
Copy link
Collaborator Author

Commented by: @hvlad

> Transaction - oldest = 5
> Transaction - oldest active = 21009
> Transaction - oldest snapshot = 6
> Transaction - Next = 21011

auto sweep will start when OST - OIT > sweep_interval
in your case OST - OIT is 1, so no need to start auto sweep

@firebird-automations
Copy link
Collaborator Author

Modified by: @hvlad

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Won't Fix [ 2 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

status: Resolved [ 5 ] => Closed [ 6 ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant