Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Commit

Permalink
TransactionManagers#createInMemory uses synchronous unlocker. (#7309)
Browse files Browse the repository at this point in the history
TransactionManagers#createInMemory uses synchronous unlocker.
  • Loading branch information
jkozlowski authored Oct 7, 2024
1 parent 26a781c commit 8c95960
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand Down
5 changes: 5 additions & 0 deletions changelog/@unreleased/pr-7309.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type: improvement
improvement:
description: TransactionManagers#createInMemory uses synchronous unlocker.
links:
- https://github.com/palantir/atlasdb/pull/7309

0 comments on commit 8c95960

Please sign in to comment.