You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@impala.apache.org by "Quanlong Huang (Code Review)" <ge...@cloudera.org> on 2022/10/12 02:02:51 UTC

[Impala-ASF-CR](branch-4.1.1) IMPALA-11631 Fix impala crashes in impala::TopNNode::Heap::Close()

Hello Abhishek Rawat, Impala Public Jenkins,

I'd like you to do a code review. Please visit

    http://gerrit.cloudera.org:8080/19127

to review the following change.


Change subject: IMPALA-11631 Fix impala crashes in impala::TopNNode::Heap::Close()
......................................................................

IMPALA-11631 Fix impala crashes in impala::TopNNode::Heap::Close()

The bug is introduced by IMPALA-11631, if RematerializeTuples()
fails in ReclaimTuplePool(), it returns immediately with an error,
however, some Heap unique_ptr in the partition_heaps_ could be
already moved to the rematerialized_heaps, and set to nullptr,
while the Close() of the TopNNode will try to call Close() on all
the Heap unique_ptr in the partition_heaps_, which leads to a
crash.

There could be two issues, the calling on a nullptr as described
above and a potential memory leaking. Because Heap doesn't call
Close() in the destructor, the unique_ptr may not release all
the resources properly if we don't call the Close() explicitly
for the Heap.

The patch changes the logic of moving each Heap object after
one rematerialize process succeeds, instead, we will move all the
Heap objects in the partition_heaps_ only when all the rematerialize
processes succeed. Therefore, there will be no half released
partition_heaps_, all the Heap should be called Close() during the
TopNNode closing. Also, added checking for nullptr Heaps in the
Close() process of TopNNode.

Because it could be difficult for a testcase to inject an error
for this case to create a crash. I did some hacking in the
code to inject a memory allocation failure in certain cases,
reproduced the issue, and proved the patch can solve the issue
manually.

Tests:
Ran core tests.
Manual test.

Change-Id: Iaf45b6ef777f68e1843c076a935e4189acc6990b
Reviewed-on: http://gerrit.cloudera.org:8080/19087
Reviewed-by: Abhishek Rawat <ar...@cloudera.com>
Tested-by: Impala Public Jenkins <im...@cloudera.com>
---
M be/src/exec/topn-node.cc
1 file changed, 9 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/27/19127/1
-- 
To view, visit http://gerrit.cloudera.org:8080/19127
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: branch-4.1.1
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iaf45b6ef777f68e1843c076a935e4189acc6990b
Gerrit-Change-Number: 19127
Gerrit-PatchSet: 1
Gerrit-Owner: Quanlong Huang <hu...@gmail.com>
Gerrit-Reviewer: Abhishek Rawat <ar...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>

[Impala-ASF-CR](branch-4.1.1) IMPALA-11631 Fix impala crashes in impala::TopNNode::Heap::Close()

Posted by "Yida Wu (Code Review)" <ge...@cloudera.org>.
Yida Wu has posted comments on this change. ( http://gerrit.cloudera.org:8080/19127 )

Change subject: IMPALA-11631 Fix impala crashes in impala::TopNNode::Heap::Close()
......................................................................


Patch Set 1: Code-Review+1

LGTM.


-- 
To view, visit http://gerrit.cloudera.org:8080/19127
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: branch-4.1.1
Gerrit-MessageType: comment
Gerrit-Change-Id: Iaf45b6ef777f68e1843c076a935e4189acc6990b
Gerrit-Change-Number: 19127
Gerrit-PatchSet: 1
Gerrit-Owner: Quanlong Huang <hu...@gmail.com>
Gerrit-Reviewer: Abhishek Rawat <ar...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Wed, 12 Oct 2022 02:17:23 +0000
Gerrit-HasComments: No

[Impala-ASF-CR](branch-4.1.1) IMPALA-11631 Fix impala crashes in impala::TopNNode::Heap::Close()

Posted by "Yida Wu (Code Review)" <ge...@cloudera.org>.
Yida Wu has posted comments on this change. ( http://gerrit.cloudera.org:8080/19127 )

Change subject: IMPALA-11631 Fix impala crashes in impala::TopNNode::Heap::Close()
......................................................................


Patch Set 2: Code-Review+1


-- 
To view, visit http://gerrit.cloudera.org:8080/19127
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: branch-4.1.1
Gerrit-MessageType: comment
Gerrit-Change-Id: Iaf45b6ef777f68e1843c076a935e4189acc6990b
Gerrit-Change-Number: 19127
Gerrit-PatchSet: 2
Gerrit-Owner: Quanlong Huang <hu...@gmail.com>
Gerrit-Reviewer: Abhishek Rawat <ar...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Wed, 12 Oct 2022 16:15:30 +0000
Gerrit-HasComments: No

[Impala-ASF-CR](branch-4.1.1) IMPALA-11631 Fix impala crashes in impala::TopNNode::Heap::Close()

Posted by "Abhishek Rawat (Code Review)" <ge...@cloudera.org>.
Abhishek Rawat has posted comments on this change. ( http://gerrit.cloudera.org:8080/19127 )

Change subject: IMPALA-11631 Fix impala crashes in impala::TopNNode::Heap::Close()
......................................................................


Patch Set 2: Code-Review+2


-- 
To view, visit http://gerrit.cloudera.org:8080/19127
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: branch-4.1.1
Gerrit-MessageType: comment
Gerrit-Change-Id: Iaf45b6ef777f68e1843c076a935e4189acc6990b
Gerrit-Change-Number: 19127
Gerrit-PatchSet: 2
Gerrit-Owner: Quanlong Huang <hu...@gmail.com>
Gerrit-Reviewer: Abhishek Rawat <ar...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Wed, 12 Oct 2022 16:20:17 +0000
Gerrit-HasComments: No

[Impala-ASF-CR](branch-4.1.1) IMPALA-11631 Fix impala crashes in impala::TopNNode::Heap::Close()

Posted by "Quanlong Huang (Code Review)" <ge...@cloudera.org>.
Quanlong Huang has posted comments on this change. ( http://gerrit.cloudera.org:8080/19127 )

Change subject: IMPALA-11631 Fix impala crashes in impala::TopNNode::Heap::Close()
......................................................................


Patch Set 2: Verified+1

Verified in https://gerrit.cloudera.org/c/19129


-- 
To view, visit http://gerrit.cloudera.org:8080/19127
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: branch-4.1.1
Gerrit-MessageType: comment
Gerrit-Change-Id: Iaf45b6ef777f68e1843c076a935e4189acc6990b
Gerrit-Change-Number: 19127
Gerrit-PatchSet: 2
Gerrit-Owner: Quanlong Huang <hu...@gmail.com>
Gerrit-Reviewer: Abhishek Rawat <ar...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Quanlong Huang <hu...@gmail.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>
Gerrit-Comment-Date: Wed, 12 Oct 2022 23:04:39 +0000
Gerrit-HasComments: No

[Impala-ASF-CR](branch-4.1.1) IMPALA-11631 Fix impala crashes in impala::TopNNode::Heap::Close()

Posted by "Quanlong Huang (Code Review)" <ge...@cloudera.org>.
Quanlong Huang has submitted this change and it was merged. ( http://gerrit.cloudera.org:8080/19127 )

Change subject: IMPALA-11631 Fix impala crashes in impala::TopNNode::Heap::Close()
......................................................................

IMPALA-11631 Fix impala crashes in impala::TopNNode::Heap::Close()

The bug is introduced by IMPALA-11631, if RematerializeTuples()
fails in ReclaimTuplePool(), it returns immediately with an error,
however, some Heap unique_ptr in the partition_heaps_ could be
already moved to the rematerialized_heaps, and set to nullptr,
while the Close() of the TopNNode will try to call Close() on all
the Heap unique_ptr in the partition_heaps_, which leads to a
crash.

There could be two issues, the calling on a nullptr as described
above and a potential memory leaking. Because Heap doesn't call
Close() in the destructor, the unique_ptr may not release all
the resources properly if we don't call the Close() explicitly
for the Heap.

The patch changes the logic of moving each Heap object after
one rematerialize process succeeds, instead, we will move all the
Heap objects in the partition_heaps_ only when all the rematerialize
processes succeed. Therefore, there will be no half released
partition_heaps_, all the Heap should be called Close() during the
TopNNode closing. Also, added checking for nullptr Heaps in the
Close() process of TopNNode.

Because it could be difficult for a testcase to inject an error
for this case to create a crash. I did some hacking in the
code to inject a memory allocation failure in certain cases,
reproduced the issue, and proved the patch can solve the issue
manually.

Tests:
Ran core tests.
Manual test.

Change-Id: Iaf45b6ef777f68e1843c076a935e4189acc6990b
Reviewed-on: http://gerrit.cloudera.org:8080/19087
Reviewed-by: Abhishek Rawat <ar...@cloudera.com>
Tested-by: Impala Public Jenkins <im...@cloudera.com>
Reviewed-on: http://gerrit.cloudera.org:8080/19127
Reviewed-by: Yida Wu <wy...@gmail.com>
Tested-by: Quanlong Huang <hu...@gmail.com>
---
M be/src/exec/topn-node.cc
1 file changed, 9 insertions(+), 1 deletion(-)

Approvals:
  Yida Wu: Looks good to me, but someone else must approve
  Abhishek Rawat: Looks good to me, approved
  Quanlong Huang: Verified

-- 
To view, visit http://gerrit.cloudera.org:8080/19127
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: branch-4.1.1
Gerrit-MessageType: merged
Gerrit-Change-Id: Iaf45b6ef777f68e1843c076a935e4189acc6990b
Gerrit-Change-Number: 19127
Gerrit-PatchSet: 3
Gerrit-Owner: Quanlong Huang <hu...@gmail.com>
Gerrit-Reviewer: Abhishek Rawat <ar...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Quanlong Huang <hu...@gmail.com>
Gerrit-Reviewer: Yida Wu <wy...@gmail.com>