Skip to content

Commit 02127ae

Browse files
authored
fix: Address a number of liveness-related issues (#6366)
* Clarify liveness requirements for interacting with TableLocationProvider * Address liveness guarantees for LiveSuppliers in AbstractTableLocationProvider * Address transient liveness errors in static SourcePartitionedTables for the UnderlyingTableMaintainer the underlying table itself * Ensure that WeakCleanupReferences returned by the underlying LivenessReferent of a DelegatingLivenessReferent are held by the delegating implementation's getWeakReference() result * Clean up a few instances where we invoke super.destroy() in a different order than the usual from ReferenceCountedLivenessNode subclasses * Annotate ReferenceCountedLivenessNode.destroy() with @OverridingMethodsMustInvokeSuper, and ensure that this is followed in all but one documented exceptional case * RetainedReferenceTracker should only do immediate CleanupReference.cleanup() for its own (idempotent) implementation * Rename RetainedReferenceTracker.DropState to be less ambiguous * Address reachability during deferred drop for LivenessReferents retained by a RetainedReferenceTracker with enforceStrongReachability=true * Remove a few redundant LivenessScopes in QueryTableAjTest * Preserve reachability at time of enqueue when not done via cleanup. Use enforceStrongReachability more places in the testing framework and QueryTableAjTest to avoid future issues. * Separate enqueueing references to be dropped (now done before destroy) from dropping enqueued references * Make LivenessScopeStack play better with other LivenessManager implementations, not just LivenessScope
1 parent c417486 commit 02127ae

File tree

45 files changed

+458
-257
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+458
-257
lines changed

engine/table/src/main/java/io/deephaven/engine/table/impl/AddOnlyToBlinkTableAdapter.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import org.apache.commons.lang3.mutable.MutableObject;
1515
import org.jetbrains.annotations.NotNull;
1616

17+
import javax.annotation.OverridingMethodsMustInvokeSuper;
1718
import java.util.List;
1819
import java.util.Map;
1920

@@ -121,10 +122,11 @@ public void run() {
121122
}
122123
}
123124

125+
@OverridingMethodsMustInvokeSuper
124126
@Override
125127
protected void destroy() {
126-
getUpdateGraph().removeSource(this);
127128
super.destroy();
129+
getUpdateGraph().removeSource(this);
128130
}
129131
}
130132
}

engine/table/src/main/java/io/deephaven/engine/table/impl/AsOfJoinHelper.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import io.deephaven.util.SafeCloseableList;
3939
import org.jetbrains.annotations.NotNull;
4040

41+
import javax.annotation.OverridingMethodsMustInvokeSuper;
4142
import java.util.*;
4243
import java.util.function.Function;
4344
import java.util.function.Supplier;
@@ -1335,6 +1336,7 @@ public void onUpdate(TableUpdate upstream) {
13351336
result.notifyListeners(downstream);
13361337
}
13371338

1339+
@OverridingMethodsMustInvokeSuper
13381340
@Override
13391341
protected void destroy() {
13401342
super.destroy();
@@ -1516,6 +1518,7 @@ public void onUpdate(TableUpdate upstream) {
15161518
}
15171519
}
15181520

1521+
@OverridingMethodsMustInvokeSuper
15191522
@Override
15201523
protected void destroy() {
15211524
super.destroy();

engine/table/src/main/java/io/deephaven/engine/table/impl/BaseTable.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import org.jetbrains.annotations.NotNull;
4545
import org.jetbrains.annotations.Nullable;
4646

47+
import javax.annotation.OverridingMethodsMustInvokeSuper;
4748
import java.io.*;
4849
import java.util.*;
4950
import java.util.concurrent.TimeUnit;
@@ -923,6 +924,7 @@ public boolean canExecute(final long step) {
923924
return parent.satisfied(step);
924925
}
925926

927+
@OverridingMethodsMustInvokeSuper
926928
@Override
927929
protected void destroy() {
928930
super.destroy();
@@ -980,6 +982,7 @@ public boolean canExecute(final long step) {
980982
return parent.satisfied(step);
981983
}
982984

985+
@OverridingMethodsMustInvokeSuper
983986
@Override
984987
protected void destroy() {
985988
super.destroy();
@@ -1321,6 +1324,7 @@ public <T extends OperationSnapshotControl> T createSnapshotControlIfRefreshing(
13211324
// Reference Counting
13221325
// ------------------------------------------------------------------------------------------------------------------
13231326

1327+
@OverridingMethodsMustInvokeSuper
13241328
@Override
13251329
protected void destroy() {
13261330
super.destroy();

engine/table/src/main/java/io/deephaven/engine/table/impl/InstrumentedTableUpdateListenerAdapter.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import org.jetbrains.annotations.NotNull;
1818
import org.jetbrains.annotations.Nullable;
1919

20+
import javax.annotation.OverridingMethodsMustInvokeSuper;
2021
import java.io.IOException;
2122

2223
/**
@@ -92,8 +93,10 @@ public boolean canExecute(final long step) {
9293
return source.satisfied(step);
9394
}
9495

96+
@OverridingMethodsMustInvokeSuper
9597
@Override
9698
protected void destroy() {
99+
super.destroy();
97100
source.removeUpdateListener(this);
98101
if (retain) {
99102
RETENTION_CACHE.forget(this);

engine/table/src/main/java/io/deephaven/engine/table/impl/ListenerRecorder.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
import org.jetbrains.annotations.NotNull;
1515
import org.jetbrains.annotations.Nullable;
1616

17+
import javax.annotation.OverridingMethodsMustInvokeSuper;
18+
1719
/**
1820
* A listener recorder stores references to added, removed, modified, and shifted indices; and then notifies a
1921
* {@link MergedListener} that a change has occurred. The combination of a {@link ListenerRecorder} and
@@ -90,6 +92,7 @@ public boolean canExecute(final long step) {
9092
return parent.satisfied(step);
9193
}
9294

95+
@OverridingMethodsMustInvokeSuper
9396
@Override
9497
protected void destroy() {
9598
super.destroy();

engine/table/src/main/java/io/deephaven/engine/table/impl/MergedListener.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.jetbrains.annotations.NotNull;
2525
import org.jetbrains.annotations.Nullable;
2626

27+
import javax.annotation.OverridingMethodsMustInvokeSuper;
2728
import java.io.IOException;
2829
import java.lang.ref.WeakReference;
2930
import java.util.Collection;
@@ -174,11 +175,13 @@ protected void propagateError(
174175
}
175176

176177
protected boolean systemicResult() {
177-
return result == null ? false : SystemicObjectTracker.isSystemic(result);
178+
return result != null && SystemicObjectTracker.isSystemic(result);
178179
}
179180

181+
@OverridingMethodsMustInvokeSuper
180182
@Override
181183
protected void destroy() {
184+
super.destroy();
182185
recorders.forEach(ListenerRecorder::forceReferenceCountToZero);
183186
}
184187

engine/table/src/main/java/io/deephaven/engine/table/impl/ShiftObliviousInstrumentedListenerAdapter.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import org.jetbrains.annotations.NotNull;
1717
import org.jetbrains.annotations.Nullable;
1818

19+
import javax.annotation.OverridingMethodsMustInvokeSuper;
1920
import java.io.IOException;
2021

2122
/**
@@ -90,8 +91,10 @@ public boolean canExecute(final long step) {
9091
return source.satisfied(step);
9192
}
9293

94+
@OverridingMethodsMustInvokeSuper
9395
@Override
9496
protected void destroy() {
97+
super.destroy();
9598
source.removeUpdateListener(this);
9699
if (retain) {
97100
RETENTION_CACHE.forget(this);

engine/table/src/main/java/io/deephaven/engine/table/impl/SourcePartitionedTable.java

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,20 @@ protected void instrumentedRefresh() {
174174
tableLocationProvider.refresh();
175175

176176
final Collection<TableLocation> locations = new ArrayList<>();
177-
tableLocationProvider.getTableLocationKeys(
178-
tlk -> locations.add(tableLocationProvider.getTableLocation(tlk.get())),
179-
locationKeyMatcher);
180-
try (final RowSet added = sortAndAddLocations(locations.stream())) {
181-
resultRows.insert(added);
177+
try {
178+
retainReference();
179+
tableLocationProvider.getTableLocationKeys(
180+
(final LiveSupplier<ImmutableTableLocationKey> lstlk) -> {
181+
final TableLocation tableLocation = tableLocationProvider.getTableLocation(lstlk.get());
182+
manage(tableLocation);
183+
locations.add(tableLocation);
184+
},
185+
locationKeyMatcher);
186+
try (final RowSet added = sortAndAddLocations(locations.stream())) {
187+
resultRows.insert(added);
188+
}
189+
} finally {
190+
dropReference();
182191
}
183192
}
184193

@@ -204,7 +213,9 @@ private RowSet sortAndAddLocations(@NotNull final Stream<TableLocation> location
204213
resultLocationTables.ensureCapacity(constituentRowKey + 1);
205214
resultLocationTables.set(constituentRowKey, constituentTable);
206215

207-
result.manage(constituentTable);
216+
if (result.isRefreshing()) {
217+
result.manage(constituentTable);
218+
}
208219
});
209220
return initialLastRowKey == lastInsertedRowKey.get()
210221
? RowSetFactory.empty()

engine/table/src/main/java/io/deephaven/engine/table/impl/SourceTable.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.apache.commons.lang3.mutable.MutableObject;
2626
import org.jetbrains.annotations.NotNull;
2727

28+
import javax.annotation.OverridingMethodsMustInvokeSuper;
2829
import java.util.ArrayList;
2930
import java.util.Collection;
3031

@@ -310,9 +311,11 @@ public boolean subscribeForUpdates(@NotNull final TableUpdateListener listener)
310311
}
311312

312313
if (snapshotControl != null) {
314+
// noinspection MethodDoesntCallSuperMethod
313315
final ListenerImpl listener =
314316
new ListenerImpl("SourceTable.coalesce", this, resultTable) {
315317

318+
@OverridingMethodsMustInvokeSuper
316319
@Override
317320
protected void destroy() {
318321
// This impl cannot call super.destroy() because we must unsubscribe from the actual
@@ -330,6 +333,7 @@ protected void destroy() {
330333
return result.getValue();
331334
}
332335

336+
@OverridingMethodsMustInvokeSuper
333337
@Override
334338
protected void destroy() {
335339
super.destroy();

engine/table/src/main/java/io/deephaven/engine/table/impl/TimeTable.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.jetbrains.annotations.NotNull;
3030
import org.jetbrains.annotations.Nullable;
3131

32+
import javax.annotation.OverridingMethodsMustInvokeSuper;
3233
import java.time.Duration;
3334
import java.time.Instant;
3435
import java.util.Collections;
@@ -215,6 +216,7 @@ private void refresh(final boolean notifyListeners) {
215216
}
216217
}
217218

219+
@OverridingMethodsMustInvokeSuper
218220
@Override
219221
protected void destroy() {
220222
super.destroy();

0 commit comments

Comments
 (0)