IMPALA-1046: Fix race in io mgr with cancelled readers and OOM.

Change-Id: I3bce1a0444bd40528a474fb53c3af4d2b53b4aa7
Reviewed-on: http://gerrit.ent.cloudera.com:8080/3022
Reviewed-by: Srinath Shankar <sshankar@cloudera.com>
Tested-by: jenkins
IMPALA-1050: NPE error when pool placement policy cannot map user to pool

Change-Id: I53ed823ee55bee96269f4119af7da2dab25d4a7c
Reviewed-on: http://gerrit.ent.cloudera.com:8080/3028
Reviewed-by: Matthew Jacobs <mj@cloudera.com>
Tested-by: jenkins
Check RuntimeState for cancellation in sorter.

Currently, cancellation checking when a SortNode is executing only
happens when a batch is being added to the sorter (SortNode::SortInput()) or
when a batch is being retrieved from the sorter (SortNode::GetNext())

This fix passes in a RuntimeState into the Sorter instance itself, which
checks for cancellation at the following points:
i) During an in-memory sort (In Partition() and SortHelper()). In Partition(),
 the cancellation check may be delayed if the input is completely sorted.
ii) During an intermediate merge before each batch of rows from a merge is
 copied into a run.

Change-Id: I5c28c7244ee2e40627cf14542b99f872e3a8c343
Reviewed-on: http://gerrit.ent.cloudera.com:8080/3007
Reviewed-by: Srinath Shankar <sshankar@cloudera.com>
Tested-by: jenkins
IMPALA-1043: Fix incorrect resource cleanup in data stream recvr.

The issue is that resource cleanup was happening in Cancel(). This is almost
always incorrect since cancel happens asynchronously and there could be other
threads still using those resources. In this case, the blocking join is still
using the memory.

This patch moves the cleanup to Close(), which always happens synchronously,
on the main thread. This guarantees that all objects are in a good state for
cleanup.

Change-Id: I5b0ac097f64401f7f17c5ddc2b63859dda659068
Reviewed-on: http://gerrit.ent.cloudera.com:8080/3006
Reviewed-by: Nong Li <nong@cloudera.com>
Tested-by: Nong Li <nong@cloudera.com>