Issue Details (XML | Word | Printable)

Key: CORE-6370
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Minor Minor
Assignee: Adriano dos Santos Fernandes
Reporter: Jaromír Krys
Votes: 0
Watchers: 5
Operations

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

Memory leak at server, when client select computed field, which used COALESCE or CAST

Created: 24/Jul/20 08:34 AM   Updated: 28/Jul/20 12:09 PM
Component/s: Engine
Affects Version/s: 3.0.4, 3.0.6
Fix Version/s: 3.0.7

Environment: windows 3.0.6 both superserver and classic

QA Status: No test


 Description  « Hide
I have table with 350 rows - random text:
CREATE TABLE TAB1
(
  A1 Varchar(99),
  A2 Varchar(199)
);
ALTER TABLE TAB1 ADD A3 COMPUTED BY (coalesce(a1, '')||'-'||coalesce(a2, ''));
 and file try.sql:
 SELECT a3 FROM tab1;
 SELECT a3 FROM tab1;
... 5000 times
 SELECT a3 FROM tab1;
I run command:
"c:\Program Files\Firebird\Firebird_3_0\isql.exe" -u SYSDBA -p 1 -i c:\1\try.sql -o c:\1\result.txt "localhost/3051:c:\fdb\try.fdb"
Then, if I observe the firebird server in the task manager, it gradually consumes more and more memory.
However, if I select column a1 (ie uncounted) instead of a3, then the memory consumption does not increase. Also, if the computed would not use coalesce, the consumed memory does not increase (or the consumption increases much more slowly - I'm not sure).
If I use a 2.5.8 server, the memory consumption also does not increase.
commit and new transaction - no change
disconnect and connect - memory is freed

 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Jiri Cincura added a comment - 26/Jul/20 01:06 PM
I tested this on 3.0.5 x64 and I can confirm it as well.

Adriano dos Santos Fernandes added a comment - 26/Jul/20 01:33 PM
The leak happens even without data in the table?

Jaromír Krys added a comment - 27/Jul/20 11:48 AM
Yes, leak happens with empty table and 30 000 rows in try.sql

Adriano dos Santos Fernandes added a comment - 27/Jul/20 04:52 PM
Thanks for the test case. Actually it's CAST that was leaking and COALESCE uses CAST internally.

Adriano dos Santos Fernandes added a comment - 27/Jul/20 05:06 PM
Please test in the next v3 snapshot.

Jaromír Krys added a comment - 28/Jul/20 12:09 PM
Tested by try.sql - OK - many thanks
In real database - will be tested - not in snapshot