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

BAT leak in some aggregate queries #4060

Closed
monetdb-team opened this issue Nov 30, 2020 · 0 comments
Closed

BAT leak in some aggregate queries #4060

monetdb-team opened this issue Nov 30, 2020 · 0 comments
Labels

Comments

@monetdb-team
Copy link

@monetdb-team monetdb-team commented Nov 30, 2020

Date: 2016-08-26 17:21:12 +0200
From: Richard Hughes <<richard.monetdb>>
To: MonetDB5 devs <>
Version: 11.23.7 (Jun2016-SP1)

Last updated: 2016-10-13 10:04:40 +0200

Comment 22326

Date: 2016-08-26 17:21:12 +0200
From: Richard Hughes <<richard.monetdb>>

[NB: I'm using Jul2015 7766a2274ca7 but the code in question hasn't change in trunk so I'm guessing the bug is still present]

To reproduce from a blank database:
create table a (id int);
create table b (id int);
select count(*) from (select * from a union all select * from b) z;

Each time that last statement is executed, one BAT is leaked, as measured by "select count(*) from sys.bbp() where kind='transient';"

Explain is:

function user.s2_1{autoCommit=true}():void;
X_39:void := querylog.define("explain select count(*) from (select * from a union all select * from b) z;","default_pipe",26);
barrier X_52 := language.dataflow();
X_3:bat[:oid,:wrd] := bat.new(nil:oid,nil:wrd);
X_2 := sql.mvc();
X_6:bat[:oid,:oid] := sql.tid(X_2,"sys","a");
X_9:bat[:oid,:int] := sql.bind(X_2,"sys","a","id",0);
(X_12,r1_12) := sql.bind(X_2,"sys","a","id",2);
X_15:bat[:oid,:int] := sql.bind(X_2,"sys","a","id",1);
X_17 := sql.delta(X_9,X_12,r1_12,X_15);
X_18 := algebra.leftfetchjoin(X_6,X_17);
X_19 := aggr.count(X_18);
X_20 := sql.single(X_19);
X_21 := bat.append(X_3,X_20,true);
X_22:bat[:oid,:oid] := sql.tid(X_2,"sys","b");
X_24:bat[:oid,:int] := sql.bind(X_2,"sys","b","id",0);
(X_25,r1_25) := sql.bind(X_2,"sys","b","id",2);
X_27:bat[:oid,:int] := sql.bind(X_2,"sys","b","id",1);
X_28 := sql.delta(X_24,X_25,r1_25,X_27);
X_29 := algebra.leftfetchjoin(X_22,X_28);
X_30 := aggr.count(X_29);
X_31 := bat.append(X_21,X_30,true);
X_32:wrd := aggr.sum(X_31);
exit X_52;
sql.resultSet(".L1","L1","wrd",64,0,7,X_32);
end user.s2_1;

This change seems to fix the problem for me:

diff -r e35315c7959d monetdb5/modules/mal/batExtensions.c
--- a/monetdb5/modules/mal/batExtensions.c Fri Aug 26 15:53:42 2016 +0100
+++ b/monetdb5/modules/mal/batExtensions.c Fri Aug 26 16:18:20 2016 +0100
@@ -175,7 +175,7 @@ CMDBATsingle(Client cntxt, MalBlkPtr mb,
if (ATOMextern(b->ttype))
u = (ptr) *(str *)u;
BUNappend(b, u, FALSE);

  •   BBPincref(*ret = b->batCacheid, TRUE);
    
  •   BBPkeepref(*ret = b->batCacheid);
      return MAL_SUCCEED;
    

}

Comment 22331

Date: 2016-08-29 15:07:04 +0200
From: MonetDB Mercurial Repository <>

Changeset 3894797fbda7 made by Sjoerd Mullender sjoerd@acm.org in the MonetDB repo, refers to this bug.

For complete details, see http//devmonetdborg/hg/MonetDB?cmd=changeset;node=3894797fbda7

Changeset description:

Fix reference counting.

This fixes bug #4060.

Comment 24500

Date: 2016-10-13 10:04:40 +0200
From: @sjoerdmullender

Jun2016-SP2 has been released.

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
1 participant