Skip to content

Commit ff6440a

Browse files
authored
Isolate Persistence objects in different threads. (#1166)
1 parent 14eb01f commit ff6440a

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

polaris-core/src/main/java/org/apache/polaris/core/PolarisCallContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public PolarisCallContext(
6161

6262
public static PolarisCallContext copyOf(PolarisCallContext original) {
6363
return new PolarisCallContext(
64-
original.getMetaStore(),
64+
original.getMetaStore().detach(),
6565
original.getDiagServices(),
6666
original.getConfigurationStore(),
6767
original.getClock());

polaris-core/src/main/java/org/apache/polaris/core/persistence/BasePersistence.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,4 +392,15 @@ boolean hasChildren(
392392
@Nullable PolarisEntityType optionalEntityType,
393393
long catalogId,
394394
long parentId);
395+
396+
/**
397+
* Performs operations necessary to isolate the state of {@code this} {@link BasePersistence}
398+
* instance from the state of the returned instance as far as multithreaded usage is concerned. If
399+
* the implementation has state that is not supposed to be accessed or modified by multiple
400+
* threads, it may return a copy from this method. If the implementation is thread-safe, it may
401+
* return {@code this}.
402+
*/
403+
default BasePersistence detach() {
404+
return this;
405+
}
395406
}

0 commit comments

Comments
 (0)