SpillingGrouper: Make DISK_FULL sticky. (#12764)

When we return DISK_FULL to a processing thread, it skips the rest of
the segment and the query is canceled. However, it's possible that the
next segment starts processing before cancellation can kick in. We want
that one, if it occurs, to see DISK_FULL too.
This commit is contained in:
Gian Merlino 2022-07-09 06:45:38 -07:00 committed by GitHub
parent 8dc4a155c7
commit 864b77e91a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 0 deletions

View File

@ -79,6 +79,7 @@ public class SpillingGrouper<KeyType> implements Grouper<KeyType>
private final List<File> dictionaryFiles = new ArrayList<>(); private final List<File> dictionaryFiles = new ArrayList<>();
private final boolean sortHasNonGroupingFields; private final boolean sortHasNonGroupingFields;
private boolean diskFull = false;
private boolean spillingAllowed; private boolean spillingAllowed;
public SpillingGrouper( public SpillingGrouper(
@ -171,6 +172,13 @@ public class SpillingGrouper<KeyType> implements Grouper<KeyType>
@Override @Override
public AggregateResult aggregate(KeyType key, int keyHash) public AggregateResult aggregate(KeyType key, int keyHash)
{ {
if (diskFull) {
// If the prior return was DISK_FULL, then return it again. When we return DISK_FULL to a processing thread,
// it skips the rest of the segment and the query is canceled. However, it's possible that the next segment
// starts processing before cancellation can kick in. We want that one, if it occurs, to see DISK_FULL too.
return DISK_FULL;
}
final AggregateResult result = grouper.aggregate(key, keyHash); final AggregateResult result = grouper.aggregate(key, keyHash);
if (result.isOk() || !spillingAllowed || temporaryStorage.maxSize() <= 0) { if (result.isOk() || !spillingAllowed || temporaryStorage.maxSize() <= 0) {
@ -184,6 +192,7 @@ public class SpillingGrouper<KeyType> implements Grouper<KeyType>
spill(); spill();
} }
catch (TemporaryStorageFullException e) { catch (TemporaryStorageFullException e) {
diskFull = true;
return DISK_FULL; return DISK_FULL;
} }
catch (IOException e) { catch (IOException e) {