{"action":"opened","number":260,"pull_request":{"url":"https://api.github.com/repos/greenplum-db/gpdb/pulls/260","id":55696027,"html_url":"https://github.com/greenplum-db/gpdb/pull/260","diff_url":"https://github.com/greenplum-db/gpdb/pull/260.diff","patch_url":"https://github.com/greenplum-db/gpdb/pull/260.patch","issue_url":"https://api.github.com/repos/greenplum-db/gpdb/issues/260","number":260,"state":"open","locked":false,"title":"Fix tuple memoryleak for fast sequence number.","user":{"login":"ashwinstar","id":11396815,"avatar_url":"https://avatars.githubusercontent.com/u/11396815?v=3","gravatar_id":"","url":"https://api.github.com/users/ashwinstar","html_url":"https://github.com/ashwinstar","followers_url":"https://api.github.com/users/ashwinstar/followers","following_url":"https://api.github.com/users/ashwinstar/following{/other_user}","gists_url":"https://api.github.com/users/ashwinstar/gists{/gist_id}","starred_url":"https://api.github.com/users/ashwinstar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ashwinstar/subscriptions","organizations_url":"https://api.github.com/users/ashwinstar/orgs","repos_url":"https://api.github.com/users/ashwinstar/repos","events_url":"https://api.github.com/users/ashwinstar/events{/privacy}","received_events_url":"https://api.github.com/users/ashwinstar/received_events","type":"User","site_admin":false},"body":"Every 100th AO or CO row insert in a transaction leaks 64 bytes\r\n(gpgastsequence tuple) memory. Hence for transaction performing bulk\r\ninserts to AO or CO table memory footprint keeps increasing, without\r\nthe fix.\r\n\r\nSample Repro:\r\n```\r\ncreate temp table t_0001 (agt_nr integer)\r\ndistributed randomly;\r\n\r\ninsert into t_0001\r\nselect\r\n  generate_series(1,512)::integer as agt_nr\r\nfrom generate_series(1,20000);\r\n\r\nselect 't_0001' as temptable, count(*) from t_0001;\r\n\r\ncreate temp table t_0002\r\nWITH (APPENDONLY=TRUE)\r\nAS\r\nselect\r\n  a.agt_nr\r\nfrom    t_0001 a, t_0001 b\r\nwhere   a.agt_nr = b.agt_nr\r\ndistributed randomly\r\n;\r\n```\r\n\r\nWhen memory allocations are dumped reveals:\r\n```\r\npostgres=# select file, line, cnt, totalsize from (select file, line, count(1) as cnt, sum(size) as totalsize from memalloc group by file, line) tmpt order by totalsize desc limit 20;\r\n                         file                         | line  |   cnt   | totalsize\r\n------------------------------------------------------+-------+---------+-----------\r\n heaptuple.c                                          |   666 | 3139698 | 200952512\r\n tupdesc.c                                            |    64 |     212 |    217664\r\n catcache.c                                           |   750 |      39 |    193928\r\n xlog.c                                               | 11677 |       1 |    163904\r\n dynahash.c                                           |   221 |     104 |    125824\r\n md.c                                                 |  2224 |      68 |    119104\r\n cdbappendonlystoragewrite.c                          |   151 |       1 |     98304\r\n mcxt.c                                               |  1009 |     373 |     96288\r\n ../../../../src/include/cdb/cdbicudpfaultinjection.h |   533 |      11 |     84264\r\n mcxt.c                                               |  1283 |    1707 |     60988\r\n deadlock.c                                           |   179 |       1 |     48000\r\n cdbmirroredbufferpool.c                              |   731 |       1 |     32768\r\n buffile.c                                            |    87 |       1 |     32768\r\n relcache.c                                           |  1464 |     100 |     27200\r\n postmaster.c                                         |  2672 |       1 |     22088\r\n heaptuple.c                                          |   697 |     114 |     21536\r\n relcache.c                                           |   738 |      79 |     20000\r\n relcache.c                                           |  4198 |      39 |     19968\r\n relcache.c                                           |   760 |      78 |     19968\r\n deadlock.c                                           |   138 |       1 |     18000\r\n(20 rows)\r\n\r\n\r\npostgres=# select file, line, cnt, totalsize from (select file, line, count(1) as cnt, sum(size) as totalsize from memalloc group by file, line) tmpt order by totalsize desc limit 20;\r\n                         file                         | line  |   cnt   | totalsize\r\n------------------------------------------------------+-------+---------+-----------\r\n heaptuple.c                                          |   666 | 4648831 | 297537024\r\n tupdesc.c                                            |    64 |     212 |    217664\r\n catcache.c                                           |   750 |      39 |    193928\r\n xlog.c                                               | 11677 |       1 |    163904\r\n dynahash.c                                           |   221 |     104 |    125824\r\n md.c                                                 |  2224 |      68 |    119104\r\n cdbappendonlystoragewrite.c                          |   151 |       1 |     98304\r\n mcxt.c                                               |  1009 |     373 |     96288\r\n ../../../../src/include/cdb/cdbicudpfaultinjection.h |   533 |      11 |     84264\r\n mcxt.c                                               |  1283 |    1707 |     60988\r\n deadlock.c                                           |   179 |       1 |     48000\r\n nbtree.c                                             |   446 |       1 |     32808\r\n buffile.c                                            |    87 |       1 |     32768\r\n cdbmirroredbufferpool.c                              |   731 |       1 |     32768\r\n relcache.c                                           |  1464 |     100 |     27200\r\n postmaster.c                                         |  2672 |       1 |     22088\r\n heaptuple.c                                          |   697 |     114 |     21536\r\n relcache.c                                           |   738 |      79 |     20000\r\n relcache.c                                           |   760 |      78 |     19968\r\n relcache.c                                           |  4198 |      39 |     19968\r\n(20 rows)\r\n\r\n\r\n(lldb) bt\r\n* thread #1: tid = 0x29011b, 0x00008209 postgres`heaptuple_copy_to(tuple=0x2f8d4f84, dest=0x00000000, destlen=0x00000000) + 178 at heaptuple.c:666, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1\r\n  * frame #0: 0x00008209 postgres`heaptuple_copy_to(tuple=0x2f8d4f84, dest=0x00000000, destlen=0x00000000) + 178 at heaptuple.c:666\r\n    frame #1: 0x00128272 postgres`heap_copytuple(tuple=0x2f8d4f84) + 33 at heapam.h:303\r\n    frame #2: 0x0012935e postgres`caql_getfirst_only(pCtx0=0xbfffe344, pbOnly=0x00000000, pcql=0x2f8d4f00) + 490 at catquery.c:616\r\n    frame #3: 0x0015b86f postgres`GetFastSequences(objid=505292, objmod=0, minSequence=464874301, numSequences=100) + 259 at gp_fastsequence.c:205\r\n    frame #4: 0x000f7879 postgres`appendonly_insert(aoInsertDesc=0x063ac62c, instup=0x043cccac, tupleOid=0xbfffe598, aoTupleId=0xbfffe592) + 2641 at appendonlyam.c:3133\r\n    frame #5: 0x0027ce1d postgres`intorel_receive(slot=0x0639d1b4, self=0x043cc53c) + 221 at execMain.c:4013\r\n    frame #6: 0x0027b0db postgres`ExecSelect(slot=0x0639d1b4, dest=0x043cc53c, estate=0x0639c42c) + 26 at execMain.c:2838\r\n    frame #7: 0x0027af3c postgres`ExecutePlan(estate=0x0639c42c, planstate=0x0639d5c8, operation=CMD_SELECT, numberTuples=0, direction=ForwardScanDirection, dest=0x043cc53c) + 1417 at execMain.c:2760\r\n    frame #8: 0x002776ae postgres`ExecutorRun(queryDesc=0x0637bbe0, direction=ForwardScanDirection, count=0) + 933 at execMain.c:911\r\n    frame #9: 0x00483010 postgres`ProcessQuery(portal=0x03bbb42c, stmt=0x06372448, params=0x00000000, dest=0x06378a24, completionTag=0xbfffe94e) + 854 at pquery.c:287\r\n    frame #10: 0x00485524 postgres`PortalRunMulti(portal=0x03bbb42c, isTopLevel='\\x01', dest=0x06378a24, altdest=0x06378a24, completionTag=0xbfffe94e) + 628 at pquery.c:1603\r\n    frame #11: 0x004846f5 postgres`PortalRun(portal=0x03bbb42c, count=9223372036854775807, isTopLevel='\\x01', dest=0x06378a24, altdest=0x06378a24, completionTag=0xbfffe94e) + 971 at pquery.c:1125\r\n    frame #12: 0x0047a8d1 postgres`exec_mpp_query(query_string=0x033f6136, serializedQuerytree=0x00000000, serializedQuerytreelen=0, serializedPlantree=0x033f61cb, serializedPlantreelen=594, serializedParams=0x00000000, serializedParamslen=0, serializedSliceInfo=0x033f641d, serializedSliceInfolen=165, seqServerHost=0x033f64c2, seqServerPort=57930, localSlice=0) + 3641 at postgres.c:1293\r\n    frame #13: 0x004817a1 postgres`PostgresMain(argc=1, argv=0x03b752cc, dbname=0x03b75264, username=0x03b75238) + 5557 at postgres.c:4824\r\n    frame #14: 0x0040e7a4 postgres`BackendRun(port=0x02b9b870) + 702 at postmaster.c:6704\r\n    frame #15: 0x0040dd65 postgres`BackendStartup(port=0x02b9b870) + 381 at postmaster.c:6391\r\n    frame #16: 0x0040579d postgres`ServerLoop + 1122 at postmaster.c:2450\r\n    frame #17: 0x00403919 postgres`PostmasterMain(argc=15, argv=0x02b9b460) + 5694 at postmaster.c:1526\r\n    frame #18: 0x0032081c postgres`main(argc=15, argv=0x02b9b460) + 840 at main.c:206\r\n    frame #19: 0x000024b5 postgres`start + 53\r\n```\r\n\r\n","created_at":"2016-01-11T23:51:13Z","updated_at":"2016-01-11T23:51:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/greenplum-db/gpdb/pulls/260/commits","review_comments_url":"https://api.github.com/repos/greenplum-db/gpdb/pulls/260/comments","review_comment_url":"https://api.github.com/repos/greenplum-db/gpdb/pulls/comments{/number}","comments_url":"https://api.github.com/repos/greenplum-db/gpdb/issues/260/comments","statuses_url":"https://api.github.com/repos/greenplum-db/gpdb/statuses/86c76057ed802c56663cb76885fdbf115e30bc75","head":{"label":"ashwinstar:memleak","ref":"memleak","sha":"86c76057ed802c56663cb76885fdbf115e30bc75","user":{"login":"ashwinstar","id":11396815,"avatar_url":"https://avatars.githubusercontent.com/u/11396815?v=3","gravatar_id":"","url":"https://api.github.com/users/ashwinstar","html_url":"https://github.com/ashwinstar","followers_url":"https://api.github.com/users/ashwinstar/followers","following_url":"https://api.github.com/users/ashwinstar/following{/other_user}","gists_url":"https://api.github.com/users/ashwinstar/gists{/gist_id}","starred_url":"https://api.github.com/users/ashwinstar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ashwinstar/subscriptions","organizations_url":"https://api.github.com/users/ashwinstar/orgs","repos_url":"https://api.github.com/users/ashwinstar/repos","events_url":"https://api.github.com/users/ashwinstar/events{/privacy}","received_events_url":"https://api.github.com/users/ashwinstar/received_events","type":"User","site_admin":false},"repo":{"id":45129886,"name":"gpdb","full_name":"ashwinstar/gpdb","owner":{"login":"ashwinstar","id":11396815,"avatar_url":"https://avatars.githubusercontent.com/u/11396815?v=3","gravatar_id":"","url":"https://api.github.com/users/ashwinstar","html_url":"https://github.com/ashwinstar","followers_url":"https://api.github.com/users/ashwinstar/followers","following_url":"https://api.github.com/users/ashwinstar/following{/other_user}","gists_url":"https://api.github.com/users/ashwinstar/gists{/gist_id}","starred_url":"https://api.github.com/users/ashwinstar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ashwinstar/subscriptions","organizations_url":"https://api.github.com/users/ashwinstar/orgs","repos_url":"https://api.github.com/users/ashwinstar/repos","events_url":"https://api.github.com/users/ashwinstar/events{/privacy}","received_events_url":"https://api.github.com/users/ashwinstar/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ashwinstar/gpdb","description":"Pivotal Greenplum Database","fork":true,"url":"https://api.github.com/repos/ashwinstar/gpdb","forks_url":"https://api.github.com/repos/ashwinstar/gpdb/forks","keys_url":"https://api.github.com/repos/ashwinstar/gpdb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ashwinstar/gpdb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ashwinstar/gpdb/teams","hooks_url":"https://api.github.com/repos/ashwinstar/gpdb/hooks","issue_events_url":"https://api.github.com/repos/ashwinstar/gpdb/issues/events{/number}","events_url":"https://api.github.com/repos/ashwinstar/gpdb/events","assignees_url":"https://api.github.com/repos/ashwinstar/gpdb/assignees{/user}","branches_url":"https://api.github.com/repos/ashwinstar/gpdb/branches{/branch}","tags_url":"https://api.github.com/repos/ashwinstar/gpdb/tags","blobs_url":"https://api.github.com/repos/ashwinstar/gpdb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ashwinstar/gpdb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ashwinstar/gpdb/git/refs{/sha}","trees_url":"https://api.github.com/repos/ashwinstar/gpdb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ashwinstar/gpdb/statuses/{sha}","languages_url":"https://api.github.com/repos/ashwinstar/gpdb/languages","stargazers_url":"https://api.github.com/repos/ashwinstar/gpdb/stargazers","contributors_url":"https://api.github.com/repos/ashwinstar/gpdb/contributors","subscribers_url":"https://api.github.com/repos/ashwinstar/gpdb/subscribers","subscription_url":"https://api.github.com/repos/ashwinstar/gpdb/subscription","commits_url":"https://api.github.com/repos/ashwinstar/gpdb/commits{/sha}","git_commits_url":"https://api.github.com/repos/ashwinstar/gpdb/git/commits{/sha}","comments_url":"https://api.github.com/repos/ashwinstar/gpdb/comments{/number}","issue_comment_url":"https://api.github.com/repos/ashwinstar/gpdb/issues/comments{/number}","contents_url":"https://api.github.com/repos/ashwinstar/gpdb/contents/{+path}","compare_url":"https://api.github.com/repos/ashwinstar/gpdb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ashwinstar/gpdb/merges","archive_url":"https://api.github.com/repos/ashwinstar/gpdb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ashwinstar/gpdb/downloads","issues_url":"https://api.github.com/repos/ashwinstar/gpdb/issues{/number}","pulls_url":"https://api.github.com/repos/ashwinstar/gpdb/pulls{/number}","milestones_url":"https://api.github.com/repos/ashwinstar/gpdb/milestones{/number}","notifications_url":"https://api.github.com/repos/ashwinstar/gpdb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ashwinstar/gpdb/labels{/name}","releases_url":"https://api.github.com/repos/ashwinstar/gpdb/releases{/id}","created_at":"2015-10-28T17:27:21Z","updated_at":"2015-10-28T17:28:07Z","pushed_at":"2016-01-11T23:03:20Z","git_url":"git://github.com/ashwinstar/gpdb.git","ssh_url":"git@github.com:ashwinstar/gpdb.git","clone_url":"https://github.com/ashwinstar/gpdb.git","svn_url":"https://github.com/ashwinstar/gpdb","homepage":"http://greenplum.org","size":120303,"stargazers_count":0,"watchers_count":0,"language":"PLpgSQL","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"greenplum-db:master","ref":"master","sha":"299425bc14b75746db687652f09cf8f1f824eefa","user":{"login":"greenplum-db","id":14097842,"avatar_url":"https://avatars.githubusercontent.com/u/14097842?v=3","gravatar_id":"","url":"https://api.github.com/users/greenplum-db","html_url":"https://github.com/greenplum-db","followers_url":"https://api.github.com/users/greenplum-db/followers","following_url":"https://api.github.com/users/greenplum-db/following{/other_user}","gists_url":"https://api.github.com/users/greenplum-db/gists{/gist_id}","starred_url":"https://api.github.com/users/greenplum-db/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/greenplum-db/subscriptions","organizations_url":"https://api.github.com/users/greenplum-db/orgs","repos_url":"https://api.github.com/users/greenplum-db/repos","events_url":"https://api.github.com/users/greenplum-db/events{/privacy}","received_events_url":"https://api.github.com/users/greenplum-db/received_events","type":"Organization","site_admin":false},"repo":{"id":44781140,"name":"gpdb","full_name":"greenplum-db/gpdb","owner":{"login":"greenplum-db","id":14097842,"avatar_url":"https://avatars.githubusercontent.com/u/14097842?v=3","gravatar_id":"","url":"https://api.github.com/users/greenplum-db","html_url":"https://github.com/greenplum-db","followers_url":"https://api.github.com/users/greenplum-db/followers","following_url":"https://api.github.com/users/greenplum-db/following{/other_user}","gists_url":"https://api.github.com/users/greenplum-db/gists{/gist_id}","starred_url":"https://api.github.com/users/greenplum-db/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/greenplum-db/subscriptions","organizations_url":"https://api.github.com/users/greenplum-db/orgs","repos_url":"https://api.github.com/users/greenplum-db/repos","events_url":"https://api.github.com/users/greenplum-db/events{/privacy}","received_events_url":"https://api.github.com/users/greenplum-db/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/greenplum-db/gpdb","description":"Greenplum Database","fork":false,"url":"https://api.github.com/repos/greenplum-db/gpdb","forks_url":"https://api.github.com/repos/greenplum-db/gpdb/forks","keys_url":"https://api.github.com/repos/greenplum-db/gpdb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/greenplum-db/gpdb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/greenplum-db/gpdb/teams","hooks_url":"https://api.github.com/repos/greenplum-db/gpdb/hooks","issue_events_url":"https://api.github.com/repos/greenplum-db/gpdb/issues/events{/number}","events_url":"https://api.github.com/repos/greenplum-db/gpdb/events","assignees_url":"https://api.github.com/repos/greenplum-db/gpdb/assignees{/user}","branches_url":"https://api.github.com/repos/greenplum-db/gpdb/branches{/branch}","tags_url":"https://api.github.com/repos/greenplum-db/gpdb/tags","blobs_url":"https://api.github.com/repos/greenplum-db/gpdb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/greenplum-db/gpdb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/greenplum-db/gpdb/git/refs{/sha}","trees_url":"https://api.github.com/repos/greenplum-db/gpdb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/greenplum-db/gpdb/statuses/{sha}","languages_url":"https://api.github.com/repos/greenplum-db/gpdb/languages","stargazers_url":"https://api.github.com/repos/greenplum-db/gpdb/stargazers","contributors_url":"https://api.github.com/repos/greenplum-db/gpdb/contributors","subscribers_url":"https://api.github.com/repos/greenplum-db/gpdb/subscribers","subscription_url":"https://api.github.com/repos/greenplum-db/gpdb/subscription","commits_url":"https://api.github.com/repos/greenplum-db/gpdb/commits{/sha}","git_commits_url":"https://api.github.com/repos/greenplum-db/gpdb/git/commits{/sha}","comments_url":"https://api.github.com/repos/greenplum-db/gpdb/comments{/number}","issue_comment_url":"https://api.github.com/repos/greenplum-db/gpdb/issues/comments{/number}","contents_url":"https://api.github.com/repos/greenplum-db/gpdb/contents/{+path}","compare_url":"https://api.github.com/repos/greenplum-db/gpdb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/greenplum-db/gpdb/merges","archive_url":"https://api.github.com/repos/greenplum-db/gpdb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/greenplum-db/gpdb/downloads","issues_url":"https://api.github.com/repos/greenplum-db/gpdb/issues{/number}","pulls_url":"https://api.github.com/repos/greenplum-db/gpdb/pulls{/number}","milestones_url":"https://api.github.com/repos/greenplum-db/gpdb/milestones{/number}","notifications_url":"https://api.github.com/repos/greenplum-db/gpdb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/greenplum-db/gpdb/labels{/name}","releases_url":"https://api.github.com/repos/greenplum-db/gpdb/releases{/id}","created_at":"2015-10-23T00:25:17Z","updated_at":"2016-01-11T18:53:02Z","pushed_at":"2016-01-11T23:51:13Z","git_url":"git://github.com/greenplum-db/gpdb.git","ssh_url":"git@github.com:greenplum-db/gpdb.git","clone_url":"https://github.com/greenplum-db/gpdb.git","svn_url":"https://github.com/greenplum-db/gpdb","homepage":"http://greenplum.org","size":121752,"stargazers_count":1254,"watchers_count":1254,"language":"PLpgSQL","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":288,"mirror_url":null,"open_issues_count":47,"forks":288,"open_issues":47,"watchers":1254,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/greenplum-db/gpdb/pulls/260"},"html":{"href":"https://github.com/greenplum-db/gpdb/pull/260"},"issue":{"href":"https://api.github.com/repos/greenplum-db/gpdb/issues/260"},"comments":{"href":"https://api.github.com/repos/greenplum-db/gpdb/issues/260/comments"},"review_comments":{"href":"https://api.github.com/repos/greenplum-db/gpdb/pulls/260/comments"},"review_comment":{"href":"https://api.github.com/repos/greenplum-db/gpdb/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/greenplum-db/gpdb/pulls/260/commits"},"statuses":{"href":"https://api.github.com/repos/greenplum-db/gpdb/statuses/86c76057ed802c56663cb76885fdbf115e30bc75"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":1,"additions":7,"deletions":2,"changed_files":1}}