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

Memory leak with TRIGGER ON TRANSACTION COMMIT [CORE4216] #4541

Closed
firebird-automations opened this issue Sep 12, 2013 · 9 comments
Closed

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: Valery (fr0st.brutal)

Attachments:
FB_test.zip

When a non-empty TRIGGER ON TRANSACTION COMMIT is defined, each commit leaks ~1-2 kB of memory. Seems to depend on the presence of a role when connecting.

Test DB:

============
SET SQL DIALECT 3;

SET NAMES UTF8;

CREATE DATABASE 'localhost:RTData'
USER 'SYSDBA' PASSWORD 'masterkey'
PAGE_SIZE 16384
DEFAULT CHARACTER SET UTF8 COLLATION UTF8;

SET TERM ^ ;

CREATE TRIGGER TRIG_TR_COMMIT
ACTIVE ON TRANSACTION COMMIT POSITION 0
AS
DECLARE VARIABLE Debug_Log SMALLINT;
BEGIN
select RDB$RELATION_ID from RDB$DATABASE
INTO :Debug_Log;
END
^

SET TERM ; ^

CREATE ROLE ROL_FILL_MSRS;

GRANT ROL_FILL_MSRS TO WRITER;

Memory consumption detection:
select
MON$STAT_ID as STAT_ID,
MON$STAT_GROUP as STAT_GR,
MON$MEMORY_USED as MEM_USED,
MON$MEMORY_ALLOCATED as MEM_ALLOC
from MON$MEMORY_USAGE
where MON$MEMORY_USED=(select max(MON$MEMORY_USED) from MON$MEMORY_USAGE);

==============

Steps to reproduce:
1. Add user WRITER
2. Connect as WRITER with role ROL_FILL_MSRS and cycle performing a commit. See the memory consumption grow.

Notes:
1. Empty trigger with begin..end only or even "begin if (something) then begin end end" doesn't produce a leak.
2. Executing as SYSDBA doesn't produce a leak.
3. Executing as WRITER with no role doesn't produce a leak.

Commits: 8ee66e0 4924dd7 FirebirdSQL/fbt-repository@e149c37 FirebirdSQL/fbt-repository@3d910cd

@firebird-automations
Copy link
Collaborator Author

Commented by: Valery (fr0st.brutal)

Attaching full testing kit including memory monitoring script, commit executer and ready-to-use DB file.
How to use (presuming you have already created user WRITER and added alias RTData):
1. If your SYSDBA password differs from masterkey, change the value in isql_shell_boss.bat
2. Run Mem_mon.bat, it will constantly output current memory values to mem.log file.
3. Run Tester.bat to perform repeating commits

Sleep.exe is a program that simply makes pause.

@firebird-automations
Copy link
Collaborator Author

Modified by: Valery (fr0st.brutal)

Attachment: FB_test.zip [ 12371 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @hvlad

assignee: Vlad Khorsun [ hvlad ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @hvlad

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

resolution: Fixed [ 1 ]

Fix Version: 2.5.3 [ 10461 ]

Fix Version: 3.0 Alpha 2 [ 10560 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @hvlad

Version: 3.0 Alpha 1 [ 10331 ]

Version: 2.5.2 [ 10450 ]

Version: 2.5.1 [ 10333 ]

Version: 2.5.0 [ 10221 ]

Version: 2.5.3 [ 10461 ] =>

@firebird-automations
Copy link
Collaborator Author

Commented by: @hvlad

The small memory leak occurs at any database trigger which body contains at least one DML statement.

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

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

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

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

QA Status: No test

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

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

QA Status: No test => Done successfully

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