HAWQ-1525. Segmentation fault occurs if reindex database when loading data from Hive to HAWQ using hcatalog
Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/fd9073c6 Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/fd9073c6 Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/fd9073c6 Branch: refs/heads/hdb-2.3.0.1 Commit: fd9073c6b44527fbcd5a790d51f3982615925b38 Parents: 251d9c7 Author: wcl14 <[email protected]> Authored: Thu Sep 14 14:35:24 2017 +0800 Committer: wcl14 <[email protected]> Committed: Thu Sep 14 14:48:11 2017 +0800 ---------------------------------------------------------------------- src/backend/cdb/cdbinmemheapam.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/fd9073c6/src/backend/cdb/cdbinmemheapam.c ---------------------------------------------------------------------- diff --git a/src/backend/cdb/cdbinmemheapam.c b/src/backend/cdb/cdbinmemheapam.c index 7f15790..db08bbf 100644 --- a/src/backend/cdb/cdbinmemheapam.c +++ b/src/backend/cdb/cdbinmemheapam.c @@ -310,6 +310,16 @@ InMemHeap_BeginScan(InMemHeapRelation memheap, int nkeys, InMemHeapScanDesc scan = palloc0(sizeof (InMemHeapScanDescData)); Assert(NULL != scan); + /* + * HAWQ-1525 + * + * The rel in InMemHeapRelation is a pointer, which is the address of heap relation + * in relcache. When the heap relation in relcache is clear for some reason, + * the value of rel in InMemHeapRelation is wrong. So we should reopen this relation + * to make sure it's correct. + */ + memheap->rel = RelationIdGetRelation(memheap->relid); + scan->rs_rd = memheap; scan->rs_nkeys = nkeys; scan->rs_index = -1; @@ -408,6 +418,8 @@ InMemHeap_EndScan(InMemHeapScanDesc scan) { Assert(NULL != scan); + RelationClose(scan->rs_rd->rel); + if (NULL != scan->rs_key) { pfree(scan->rs_key);
