Issue Details (XML | Word | Printable)

Key: CORE-4216
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Critical Critical
Assignee: Vlad Khorsun
Reporter: Valery
Votes: 0
Watchers: 5
Operations

If you were logged in you would be able to see more operations.
Firebird Core

Memory leak with TRIGGER ON TRANSACTION COMMIT

Created: 12/Sep/13 03:32 PM   Updated: 08/Feb/18 07:03 AM
Component/s: Engine
Affects Version/s: 2.5.0, 2.5.1, 2.5.2, 2.5.2 Update 1, 3.0 Alpha 1
Fix Version/s: 3.0 Alpha 2, 2.5.3

File Attachments: 1. Zip Archive FB_test.zip (534 kB)

Environment: Win 7 x64, FB V2.5.3.26690 x64 SuperClassic

QA Status: Done successfully


 Description  « Hide
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.

 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Valery added a comment - 13/Sep/13 06:16 AM - edited
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.

Vlad Khorsun added a comment - 16/Sep/13 09:20 AM
The small memory leak occurs at any database trigger which body contains at least one DML statement.