diff --git a/atlasdb-config/src/main/java/com/palantir/atlasdb/factory/TransactionManagers.java b/atlasdb-config/src/main/java/com/palantir/atlasdb/factory/TransactionManagers.java index 9df0b53032a..871869ad1d2 100644 --- a/atlasdb-config/src/main/java/com/palantir/atlasdb/factory/TransactionManagers.java +++ b/atlasdb-config/src/main/java/com/palantir/atlasdb/factory/TransactionManagers.java @@ -336,6 +336,7 @@ private static TransactionManager createInMemory( .globalMetricsRegistry(new MetricRegistry()) .globalTaggedMetricRegistry(DefaultTaggedMetricRegistry.getDefault()) .lockAndTimestampServiceFactory(maybeFactory) + .defaultTimelockClientFactory((service, _management) -> TimeLockClient.withSynchronousUnlocker(service)) .addAllSchemas(schemas) .build() .serializable(); diff --git a/atlasdb-tests-shared/src/test/java/com/palantir/atlasdb/factory/TransactionManagersTest.java b/atlasdb-tests-shared/src/test/java/com/palantir/atlasdb/factory/TransactionManagersTest.java index 5363f97e493..aac9c587600 100644 --- a/atlasdb-tests-shared/src/test/java/com/palantir/atlasdb/factory/TransactionManagersTest.java +++ b/atlasdb-tests-shared/src/test/java/com/palantir/atlasdb/factory/TransactionManagersTest.java @@ -60,6 +60,9 @@ import com.palantir.atlasdb.sweep.queue.config.ImmutableTargetedSweepInstallConfig; import com.palantir.atlasdb.sweep.queue.config.ImmutableTargetedSweepRuntimeConfig; import com.palantir.atlasdb.table.description.GenericTestSchema; +import com.palantir.atlasdb.table.description.generated.GenericTestSchemaTableFactory; +import com.palantir.atlasdb.table.description.generated.RangeScanTestTable; +import com.palantir.atlasdb.table.description.generated.RangeScanTestTable.RangeScanTestRow; import com.palantir.atlasdb.timelock.adjudicate.feedback.TimeLockClientFeedbackService; import com.palantir.atlasdb.transaction.ImmutableTransactionConfig; import com.palantir.atlasdb.transaction.TransactionConfig; @@ -684,6 +687,22 @@ public void sanityCheckFeedbackReportingPipeline() { verifyFeedbackIsReportedToService(); } + @Test + public void inMemoryUsesSynchronousUnlocker() { + TransactionManager transactionManager = TransactionManagers.createInMemory(GenericTestSchema.getSchema()); + for (int i = 0; i < 100; i++) { + long immutableTimestamp = transactionManager.getImmutableTimestamp(); + long txnTimestamp = transactionManager.runTaskWithRetry(txn -> { + assertThat(txn.getTimestamp()).isGreaterThan(immutableTimestamp); + assertThat(transactionManager.getImmutableTimestamp()).isGreaterThanOrEqualTo(immutableTimestamp); + RangeScanTestTable table = GenericTestSchemaTableFactory.of().getRangeScanTestTable(txn); + table.putColumn1(RangeScanTestRow.of("hello"), 1L); + return txn.getTimestamp(); + }); + assertThat(transactionManager.getImmutableTimestamp()).isGreaterThan(txnTimestamp); + } + } + private void setUpTimeLockConfig() { timeLockRuntimeConfig = getTimelockRuntimeConfig(ImmutableList.of(getUriForPort(availablePort))); when(mockAtlasDbRuntimeConfig.timelockRuntime()).thenReturn(Optional.of(timeLockRuntimeConfig)); diff --git a/changelog/@unreleased/pr-7309.v2.yml b/changelog/@unreleased/pr-7309.v2.yml new file mode 100644 index 00000000000..73f03828529 --- /dev/null +++ b/changelog/@unreleased/pr-7309.v2.yml @@ -0,0 +1,5 @@ +type: improvement +improvement: + description: TransactionManagers#createInMemory uses synchronous unlocker. + links: + - https://github.com/palantir/atlasdb/pull/7309