Skip to content

Commit

Permalink
[SNAP-1233] clear InMemorySorter before calling its reset (#35)
Browse files Browse the repository at this point in the history
This is done so that any spill call (due to no EVICTION_DOWN) from within the spill
call will return without doing anything, else it results in NPE trying to read
page tables which have already been cleared.
  • Loading branch information
Sumedh Wale authored and ymahajan committed Jan 13, 2017
1 parent 9447d24 commit 4cf05c9
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,17 @@ public long spill(long size, MemoryConsumer trigger) throws IOException {
// Note that this is more-or-less going to be a multiple of the page size, so wasted space in
// pages will currently be counted as memory spilled even though that space isn't actually
// written to disk. This also counts the space needed to store the sorter's pointer array.
inMemSorter.reset();

// temporarily clear inMemorySorter so that a recursive spill call will return
final UnsafeInMemorySorter memSorter = inMemSorter;
if (memSorter != null) {
inMemSorter = null;
try {
memSorter.reset();
} finally {
inMemSorter = memSorter;
}
}
// Reset the in-memory sorter's pointer array only after freeing up the memory pages holding the
// records. Otherwise, if the task is over allocated memory, then without freeing the memory
// pages, we might not be able to get memory for the pointer array.
Expand Down

0 comments on commit 4cf05c9

Please sign in to comment.