IMPALA-4995: Fix integer overflow in TopNNode::PrepareForOutput To test this, Matt Mulder ran the failing query from IMPALA-4995 on a private cluster and it did not crash. However the query did not finish within several hours. We should switch to using the Sorter for large TopN queries, as tracked by IMPALA-5004.
Change-Id: I5048ec67d8f086346220d56e027e6583fbb5ddad Reviewed-on: http://gerrit.cloudera.org:8080/6171 Reviewed-by: Lars Volker <[email protected]> Tested-by: Impala Public Jenkins Project: http://git-wip-us.apache.org/repos/asf/incubator-impala/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-impala/commit/1609585d Tree: http://git-wip-us.apache.org/repos/asf/incubator-impala/tree/1609585d Diff: http://git-wip-us.apache.org/repos/asf/incubator-impala/diff/1609585d Branch: refs/heads/master Commit: 1609585dc5e9efca8c2fcab4a08474304e04302c Parents: abe860c Author: Lars Volker <[email protected]> Authored: Mon Feb 27 15:18:37 2017 -0800 Committer: Impala Public Jenkins <[email protected]> Committed: Wed Mar 1 07:50:00 2017 +0000 ---------------------------------------------------------------------- be/src/exec/topn-node.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/1609585d/be/src/exec/topn-node.cc ---------------------------------------------------------------------- diff --git a/be/src/exec/topn-node.cc b/be/src/exec/topn-node.cc index a7f11bd..b79191f 100644 --- a/be/src/exec/topn-node.cc +++ b/be/src/exec/topn-node.cc @@ -221,7 +221,7 @@ void TopNNode::Close(RuntimeState* state) { // Reverse the order of the tuples in the priority queue void TopNNode::PrepareForOutput() { sorted_top_n_.resize(priority_queue_->size()); - int index = sorted_top_n_.size() - 1; + int64_t index = sorted_top_n_.size() - 1; while (priority_queue_->size() > 0) { Tuple* tuple = priority_queue_->top();
