Search in sources :

Example 1 with TransactionSchemaManager

use of com.palantir.atlasdb.internalschema.TransactionSchemaManager in project atlasdb by palantir.

the class TransactionManagers method getTransactionSchemaInstallerIfSupported.

private static Optional<TransactionSchemaInstaller> getTransactionSchemaInstallerIfSupported(@Output List<AutoCloseable> closeables, KeyValueService keyValueService, Supplier<AtlasDbRuntimeConfig> runtimeConfigSupplier, TransactionSchemaManager transactionSchemaManager) {
    CheckAndSetCompatibility compatibility = keyValueService.getCheckAndSetCompatibility();
    if (compatibility.supportsCheckAndSetOperations() && compatibility.supportsDetailOnFailure()) {
        return Optional.of(initializeTransactionSchemaInstaller(closeables, runtimeConfigSupplier, transactionSchemaManager));
    }
    runtimeConfigSupplier.get().internalSchema().targetTransactionsSchemaVersion().filter(version -> version != TransactionConstants.DIRECT_ENCODING_TRANSACTIONS_SCHEMA_VERSION).ifPresent(version -> log.warn("This service seems like it has been configured to use transaction schema version {}," + " which isn't supported as your KVS doesn't support details on CAS failures" + " (typically Postgres or Oracle). We will remain with transactions1.", SafeArg.of("configuredTransactionSchemaVersion", version)));
    return Optional.empty();
}
Also used : TransactionService(com.palantir.atlasdb.transaction.service.TransactionService) NoOpBackgroundSweeperPerformanceLogger(com.palantir.atlasdb.sweep.NoOpBackgroundSweeperPerformanceLogger) SafeTableClearerKeyValueService(com.palantir.atlasdb.sweep.queue.clear.SafeTableClearerKeyValueService) SharedResourcesConfig(com.palantir.atlasdb.spi.SharedResourcesConfig) TimelockTimestampServiceAdapter(com.palantir.atlasdb.transaction.impl.TimelockTimestampServiceAdapter) KeyValueServicePuncherStore(com.palantir.atlasdb.cleaner.KeyValueServicePuncherStore) TargetedSweepTableFactory(com.palantir.atlasdb.schema.generated.TargetedSweepTableFactory) LockServerOptions(com.palantir.lock.LockServerOptions) ImmutableAtlasDbConfig(com.palantir.atlasdb.config.ImmutableAtlasDbConfig) GlobalClock(com.palantir.atlasdb.cleaner.GlobalClock) TimeLockRequestBatcherProviders(com.palantir.atlasdb.config.TimeLockRequestBatcherProviders) UserAgent(com.palantir.conjure.java.api.config.service.UserAgent) CoordinationServices(com.palantir.atlasdb.internalschema.persistence.CoordinationServices) TableReference(com.palantir.atlasdb.keyvalue.api.TableReference) SerializableTransactionManager(com.palantir.atlasdb.transaction.impl.SerializableTransactionManager) InternalSchemaMetadata(com.palantir.atlasdb.internalschema.InternalSchemaMetadata) AtlasDbConstants(com.palantir.atlasdb.AtlasDbConstants) Refreshable(com.palantir.refreshable.Refreshable) SweeperServiceImpl(com.palantir.atlasdb.sweep.SweeperServiceImpl) ConflictDetectionManagers(com.palantir.atlasdb.transaction.impl.ConflictDetectionManagers) NamedThreadFactory(com.palantir.common.concurrent.NamedThreadFactory) TargetedSweepRuntimeConfig(com.palantir.atlasdb.sweep.queue.config.TargetedSweepRuntimeConfig) TargetedSweepSchema(com.palantir.atlasdb.schema.TargetedSweepSchema) TimeLockFeedbackBackgroundTask(com.palantir.lock.client.metrics.TimeLockFeedbackBackgroundTask) Set(java.util.Set) TransactionManager(com.palantir.atlasdb.transaction.api.TransactionManager) DefaultTaggedMetricRegistry(com.palantir.tritium.metrics.registry.DefaultTaggedMetricRegistry) MetricsManagers(com.palantir.atlasdb.util.MetricsManagers) SweepBatchConfig(com.palantir.atlasdb.sweep.SweepBatchConfig) ServicesConfigBlock(com.palantir.conjure.java.api.config.service.ServicesConfigBlock) KvsProfilingLogger(com.palantir.atlasdb.logging.KvsProfilingLogger) Stream(java.util.stream.Stream) MetricsFilterEvaluationContext(com.palantir.atlasdb.transaction.impl.metrics.MetricsFilterEvaluationContext) KeyValueServiceConfig(com.palantir.atlasdb.spi.KeyValueServiceConfig) ImmutableTimestampCorroborationConsistencyCheck(com.palantir.atlasdb.transaction.impl.consistency.ImmutableTimestampCorroborationConsistencyCheck) DefaultMetricsFilterEvaluationContext(com.palantir.atlasdb.transaction.impl.metrics.DefaultMetricsFilterEvaluationContext) SweepStatsKeyValueService(com.palantir.atlasdb.keyvalue.impl.SweepStatsKeyValueService) TimeLockClientConfig(com.palantir.atlasdb.config.TimeLockClientConfig) SimpleTimeDuration(com.palantir.lock.SimpleTimeDuration) LockServiceImpl(com.palantir.lock.impl.LockServiceImpl) AsyncInitializer(com.palantir.async.initializer.AsyncInitializer) Supplier(java.util.function.Supplier) ArrayList(java.util.ArrayList) ValidatingQueryRewritingKeyValueService(com.palantir.atlasdb.keyvalue.impl.ValidatingQueryRewritingKeyValueService) AtlasDbVersion(com.palantir.atlasdb.versions.AtlasDbVersion) CompactorConfig(com.palantir.atlasdb.compact.CompactorConfig) ImmutableSweepBatchConfig(com.palantir.atlasdb.sweep.ImmutableSweepBatchConfig) BackgroundCompactor(com.palantir.atlasdb.compact.BackgroundCompactor) LockRequest(com.palantir.lock.LockRequest) MetadataCoordinationServiceMetrics(com.palantir.atlasdb.internalschema.metrics.MetadataCoordinationServiceMetrics) TargetedSweepInstallConfig(com.palantir.atlasdb.sweep.queue.config.TargetedSweepInstallConfig) LockServerConfigs(com.palantir.lock.LockServerConfigs) SweepConfig(com.palantir.atlasdb.config.SweepConfig) Clock(com.palantir.common.time.Clock) MetricRegistry(com.codahale.metrics.MetricRegistry) Callback(com.palantir.async.initializer.Callback) TargetedSweeper(com.palantir.atlasdb.sweep.queue.TargetedSweeper) TransactionSchemaManager(com.palantir.atlasdb.internalschema.TransactionSchemaManager) TransactionSchemaInstaller(com.palantir.atlasdb.internalschema.TransactionSchemaInstaller) TaggedMetricRegistry(com.palantir.tritium.metrics.registry.TaggedMetricRegistry) AtlasDbRuntimeConfig(com.palantir.atlasdb.config.AtlasDbRuntimeConfig) SweepTableFactory(com.palantir.atlasdb.schema.generated.SweepTableFactory) BackgroundSweeperImpl(com.palantir.atlasdb.sweep.BackgroundSweeperImpl) Follower(com.palantir.atlasdb.cleaner.Follower) LockService(com.palantir.lock.LockService) TimeLockClient(com.palantir.lock.client.TimeLockClient) ManagedTimestampService(com.palantir.timestamp.ManagedTimestampService) UserAgents(com.palantir.conjure.java.api.config.service.UserAgents) LockClient(com.palantir.lock.LockClient) MultiTableSweepQueueWriter(com.palantir.atlasdb.sweep.queue.MultiTableSweepQueueWriter) ConflictTracer(com.palantir.atlasdb.debug.ConflictTracer) ConflictDetectionManager(com.palantir.atlasdb.transaction.impl.ConflictDetectionManager) ShouldRunBackgroundSweepSupplier(com.palantir.atlasdb.config.ShouldRunBackgroundSweepSupplier) DerivedSnapshotConfig(com.palantir.atlasdb.spi.DerivedSnapshotConfig) SweepStrategyManager(com.palantir.atlasdb.transaction.impl.SweepStrategyManager) StagedBuilderStyle(com.palantir.common.annotations.ImmutablesStyles.StagedBuilderStyle) LockRefreshingLockService(com.palantir.lock.client.LockRefreshingLockService) TimeLockClientFeedbackService(com.palantir.atlasdb.timelock.adjudicate.feedback.TimeLockClientFeedbackService) CheckAndSetCompatibility(com.palantir.atlasdb.keyvalue.api.CheckAndSetCompatibility) TransactionConfig(com.palantir.atlasdb.transaction.TransactionConfig) MetricsManager(com.palantir.atlasdb.util.MetricsManager) PTExecutors(com.palantir.common.concurrent.PTExecutors) TransactionServices(com.palantir.atlasdb.transaction.service.TransactionServices) LockWatchingCache(com.palantir.atlasdb.transaction.api.LockWatchingCache) SweepTaskRunner(com.palantir.atlasdb.sweep.SweepTaskRunner) ToLongFunction(java.util.function.ToLongFunction) ImmutableSet(com.google.common.collect.ImmutableSet) CoordinationService(com.palantir.atlasdb.coordination.CoordinationService) LockDiagnosticComponents(com.palantir.atlasdb.debug.LockDiagnosticComponents) DefaultCleanerBuilder(com.palantir.atlasdb.cleaner.DefaultCleanerBuilder) ProfilingKeyValueService(com.palantir.atlasdb.keyvalue.impl.ProfilingKeyValueService) Collectors(java.util.stream.Collectors) ServerListConfig(com.palantir.atlasdb.config.ServerListConfig) AtlasDbMetricNames(com.palantir.atlasdb.AtlasDbMetricNames) List(java.util.List) Optional(java.util.Optional) ConsistencyCheckRunner(com.palantir.atlasdb.factory.startup.ConsistencyCheckRunner) SafeLoggerFactory(com.palantir.logsafe.logger.SafeLoggerFactory) Cleaner(com.palantir.atlasdb.cleaner.api.Cleaner) AtlasDbMetrics(com.palantir.atlasdb.util.AtlasDbMetrics) Output(com.palantir.common.annotation.Output) InMemoryAtlasDbConfig(com.palantir.atlasdb.memory.InMemoryAtlasDbConfig) TimestampStoreInvalidator(com.palantir.timestamp.TimestampStoreInvalidator) AdjustableSweepBatchConfigSource(com.palantir.atlasdb.sweep.AdjustableSweepBatchConfigSource) Function(java.util.function.Function) SafeLogger(com.palantir.logsafe.logger.SafeLogger) AtlasDbConstraintCheckingMode(com.palantir.atlasdb.transaction.api.AtlasDbConstraintCheckingMode) SafeArg(com.palantir.logsafe.SafeArg) ImmutableList(com.google.common.collect.ImmutableList) Value(org.immutables.value.Value) JsonIgnore(com.fasterxml.jackson.annotation.JsonIgnore) AuxiliaryRemotingParameters(com.palantir.atlasdb.config.AuxiliaryRemotingParameters) TracingKeyValueService(com.palantir.atlasdb.keyvalue.impl.TracingKeyValueService) ImmutableTransactionConfig(com.palantir.atlasdb.transaction.ImmutableTransactionConfig) FreshTimestampSupplierAdapter(com.palantir.atlasdb.factory.timestamp.FreshTimestampSupplierAdapter) SweepStrategyManagers(com.palantir.atlasdb.transaction.impl.SweepStrategyManagers) BackgroundSweeperPerformanceLogger(com.palantir.atlasdb.sweep.BackgroundSweeperPerformanceLogger) NoOpLockWatchingCache(com.palantir.atlasdb.transaction.api.NoOpLockWatchingCache) TimestampCache(com.palantir.atlasdb.cache.TimestampCache) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) LambdaCallback(com.palantir.async.initializer.LambdaCallback) TransactionConstants(com.palantir.atlasdb.transaction.impl.TransactionConstants) SpecificTableSweeper(com.palantir.atlasdb.sweep.SpecificTableSweeper) LegacySweepMetrics(com.palantir.atlasdb.sweep.metrics.LegacySweepMetrics) KeyValueService(com.palantir.atlasdb.keyvalue.api.KeyValueService) AtlasDbRemotingConstants(com.palantir.atlasdb.http.AtlasDbRemotingConstants) CellsSweeper(com.palantir.atlasdb.sweep.CellsSweeper) VisibleForTesting(com.google.common.annotations.VisibleForTesting) DefaultTimestampCache(com.palantir.atlasdb.cache.DefaultTimestampCache) DialogueClients(com.palantir.dialogue.clients.DialogueClients) OldestTargetedSweepTrackedTimestamp(com.palantir.atlasdb.sweep.queue.OldestTargetedSweepTrackedTimestamp) Schema(com.palantir.atlasdb.table.description.Schema) Preconditions(com.palantir.logsafe.Preconditions) CleanupFollower(com.palantir.atlasdb.cleaner.CleanupFollower) AtlasDbConfig(com.palantir.atlasdb.config.AtlasDbConfig) CheckAndSetCompatibility(com.palantir.atlasdb.keyvalue.api.CheckAndSetCompatibility)

Example 2 with TransactionSchemaManager

use of com.palantir.atlasdb.internalschema.TransactionSchemaManager in project atlasdb by palantir.

the class TransactionManagers method createTransactionComponents.

private TransactionComponents createTransactionComponents(@Output List<AutoCloseable> closeables, MetricsManager metricsManager, LockAndTimestampServices lockAndTimestampServices, KeyValueService keyValueService, Supplier<AtlasDbRuntimeConfig> runtimeConfigSupplier) {
    CoordinationService<InternalSchemaMetadata> coordinationService = getSchemaMetadataCoordinationService(metricsManager, lockAndTimestampServices, keyValueService);
    TransactionSchemaManager transactionSchemaManager = new TransactionSchemaManager(coordinationService);
    TransactionService transactionService = initializeCloseable(() -> AtlasDbMetrics.instrumentTimed(metricsManager.getRegistry(), TransactionService.class, TransactionServices.createTransactionService(keyValueService, transactionSchemaManager, metricsManager.getTaggedRegistry(), () -> runtimeConfigSupplier.get().internalSchema().acceptStagingReadsOnVersionThree())), closeables);
    Optional<TransactionSchemaInstaller> schemaInstaller = getTransactionSchemaInstallerIfSupported(closeables, keyValueService, runtimeConfigSupplier, transactionSchemaManager);
    return ImmutableTransactionComponents.builder().transactionService(transactionService).schemaInstaller(schemaInstaller).build();
}
Also used : TransactionSchemaManager(com.palantir.atlasdb.internalschema.TransactionSchemaManager) TransactionService(com.palantir.atlasdb.transaction.service.TransactionService) InternalSchemaMetadata(com.palantir.atlasdb.internalschema.InternalSchemaMetadata) TransactionSchemaInstaller(com.palantir.atlasdb.internalschema.TransactionSchemaInstaller)

Example 3 with TransactionSchemaManager

use of com.palantir.atlasdb.internalschema.TransactionSchemaManager in project atlasdb by palantir.

the class TransactionServicesTest method forceInstallV2.

private void forceInstallV2() {
    TransactionSchemaManager transactionSchemaManager = new TransactionSchemaManager(coordinationService);
    Awaitility.await().atMost(Duration.ofSeconds(10)).until(() -> {
        transactionSchemaManager.tryInstallNewTransactionsSchemaVersion(2);
        ((TimestampManagementService) timestampService).fastForwardTimestamp(timestampService.getFreshTimestamp() + 1_000_000);
        return transactionSchemaManager.getTransactionsSchemaVersion(timestampService.getFreshTimestamp()) == 2;
    });
}
Also used : TransactionSchemaManager(com.palantir.atlasdb.internalschema.TransactionSchemaManager) TimestampManagementService(com.palantir.timestamp.TimestampManagementService)

Example 4 with TransactionSchemaManager

use of com.palantir.atlasdb.internalschema.TransactionSchemaManager in project atlasdb by palantir.

the class TransactionTestSetup method setUp.

@Before
public void setUp() {
    timestampCache = ComparingTimestampCache.comparingOffHeapForTests(metricsManager, persistentStore);
    lockService = LockServiceImpl.create(LockServerOptions.builder().isStandaloneServer(false).build());
    lockClient = LockClient.of("test_client");
    keyValueService = getKeyValueService();
    keyValueService.createTables(ImmutableMap.of(TEST_TABLE_THOROUGH, TableMetadata.builder().rangeScanAllowed(true).explicitCompressionBlockSizeKB(4).negativeLookups(true).sweepStrategy(SweepStrategy.THOROUGH).build().persistToBytes(), TEST_TABLE, TableMetadata.builder().rangeScanAllowed(true).explicitCompressionBlockSizeKB(4).negativeLookups(true).sweepStrategy(SweepStrategy.NOTHING).build().persistToBytes(), TEST_TABLE_SERIALIZABLE, TableMetadata.builder().rangeScanAllowed(true).explicitCompressionBlockSizeKB(4).negativeLookups(true).conflictHandler(ConflictHandler.SERIALIZABLE).sweepStrategy(SweepStrategy.NOTHING).build().persistToBytes()));
    TransactionTables.createTables(keyValueService);
    TransactionTables.truncateTables(keyValueService);
    keyValueService.truncateTable(TEST_TABLE);
    keyValueService.truncateTable(TEST_TABLE_SERIALIZABLE);
    timestampService = inMemoryTimeLockRule.getTimestampService();
    timestampManagementService = inMemoryTimeLockRule.getTimestampManagementService();
    timelockService = inMemoryTimeLockRule.getLegacyTimelockService();
    lockWatchManager = inMemoryTimeLockRule.getLockWatchManager();
    CoordinationService<InternalSchemaMetadata> coordinationService = CoordinationServices.createDefault(keyValueService, timestampService, metricsManager, false);
    transactionSchemaManager = new TransactionSchemaManager(coordinationService);
    transactionService = createTransactionService(keyValueService, transactionSchemaManager);
    conflictDetectionManager = ConflictDetectionManagers.createWithoutWarmingCache(keyValueService);
    sweepStrategyManager = SweepStrategyManagers.createDefault(keyValueService);
    txMgr = createAndRegisterManager();
}
Also used : TransactionSchemaManager(com.palantir.atlasdb.internalschema.TransactionSchemaManager) InternalSchemaMetadata(com.palantir.atlasdb.internalschema.InternalSchemaMetadata) Before(org.junit.Before)

Example 5 with TransactionSchemaManager

use of com.palantir.atlasdb.internalschema.TransactionSchemaManager in project atlasdb by palantir.

the class AtlasDbEteServer method ensureTransactionSchemaVersionInstalled.

private void ensureTransactionSchemaVersionInstalled(AtlasDbConfig config, Optional<AtlasDbRuntimeConfig> runtimeConfig, TransactionManager transactionManager) {
    if (runtimeConfig.isEmpty() || runtimeConfig.get().internalSchema().targetTransactionsSchemaVersion().isEmpty()) {
        return;
    }
    CoordinationService<InternalSchemaMetadata> coordinationService = CoordinationServices.createDefault(transactionManager.getKeyValueService(), transactionManager.getTimestampService(), MetricsManagers.createForTests(), config.initializeAsync());
    TransactionSchemaManager manager = new TransactionSchemaManager(coordinationService);
    int targetSchemaVersion = runtimeConfig.get().internalSchema().targetTransactionsSchemaVersion().get();
    TransactionSchemaVersionEnforcement.ensureTransactionsGoingForwardHaveSchemaVersion(manager, transactionManager.getTimestampService(), transactionManager.getTimestampManagementService(), targetSchemaVersion);
}
Also used : TransactionSchemaManager(com.palantir.atlasdb.internalschema.TransactionSchemaManager) InternalSchemaMetadata(com.palantir.atlasdb.internalschema.InternalSchemaMetadata)

Aggregations

TransactionSchemaManager (com.palantir.atlasdb.internalschema.TransactionSchemaManager)5 InternalSchemaMetadata (com.palantir.atlasdb.internalschema.InternalSchemaMetadata)4 TransactionSchemaInstaller (com.palantir.atlasdb.internalschema.TransactionSchemaInstaller)2 TransactionService (com.palantir.atlasdb.transaction.service.TransactionService)2 MetricRegistry (com.codahale.metrics.MetricRegistry)1 JsonIgnore (com.fasterxml.jackson.annotation.JsonIgnore)1 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 AsyncInitializer (com.palantir.async.initializer.AsyncInitializer)1 Callback (com.palantir.async.initializer.Callback)1 LambdaCallback (com.palantir.async.initializer.LambdaCallback)1 AtlasDbConstants (com.palantir.atlasdb.AtlasDbConstants)1 AtlasDbMetricNames (com.palantir.atlasdb.AtlasDbMetricNames)1 DefaultTimestampCache (com.palantir.atlasdb.cache.DefaultTimestampCache)1 TimestampCache (com.palantir.atlasdb.cache.TimestampCache)1 CleanupFollower (com.palantir.atlasdb.cleaner.CleanupFollower)1 DefaultCleanerBuilder (com.palantir.atlasdb.cleaner.DefaultCleanerBuilder)1 Follower (com.palantir.atlasdb.cleaner.Follower)1 GlobalClock (com.palantir.atlasdb.cleaner.GlobalClock)1