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

Significant memory leaks with recursive queries [CORE3208] #3582

Closed
firebird-issue-importer opened this issue Nov 1, 2010 · 4 comments
Closed

Comments

@firebird-issue-importer
Copy link

@firebird-issue-importer firebird-issue-importer commented Nov 1, 2010

Submitted by: @dyemanov

Recursive queries may leak some amount of memory from the request pool. This may be a big problem if the request is a trigger or a procedure, as this memory never gets deallocated until disconnection (or trigger/procedure recompile). In the test I have at hands (cannot be shared, unfortunately) every insert leaks about 20MB because of this issue (WITH RECURSIVE in the AFTER INSERT trigger).

All the leaked memory chunks are allocated in VIO_record():
record = rpb->rpb_record = FB_NEW_RPT(*pool, format->fmt_length) Record(*pool);
and lost after this code in RSBRecurse::get():
// Don't overwrite record contents at next level of recursion.
// RSE_open and company will allocate new record if needed
rpb->rpb_record = NULL;

I have tried the following solution in RSBRecurse::close():

	char\* tmp = irsb\-\>irsb\_stack;
	memcpy\(irsb, tmp, inner\_size\);

+ char* p = tmp + inner_size;
+ for (int i = 0; i < streams; i++)
+ {
+ record_param* rpb = (record_param*) p;
+ delete rpb->rpb_record;
+ p += sizeof(record_param);
+ }

	delete\[\] tmp;

and it seems to help (leaks disappear). Maybe a better solution could be suggested instead.

Commits: b060fb4 52ed454 d461d8f

====== Test Details ======

Could not reproduce on 2.5.0 with trivial AI trigger which uses recursive query as source to insert statement.
Any hint about how test can be done will be appreciated.

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Nov 1, 2010

Modified by: @dyemanov

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

resolution: Fixed [ 1 ]

Fix Version: 2.1.4 [ 10361 ]

Fix Version: 2.5.1 [ 10333 ]

Fix Version: 3.0 Alpha 1 [ 10331 ]

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Nov 1, 2010

Modified by: @dyemanov

assignee: Dmitry Yemanov [ dimitr ]

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Feb 4, 2011

Modified by: @pcisar

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

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Jul 19, 2015

Modified by: @pavel-zotov

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

QA Status: Not enough information

Test Details: Could not reproduce on 2.5.0 with trivial AI trigger which uses recursive query as source to insert statement.
Any hint about how test can be done will be appreciated.

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

Successfully merging a pull request may close this issue.

None yet
2 participants