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

Commit

Permalink
Revert "Clock went backwards corruption check (#5131)" (#5181)
Browse files Browse the repository at this point in the history
This reverts commit 259908a.
  • Loading branch information
sudiksha27 authored Jan 7, 2021
1 parent ad2f984 commit 7f6c373
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 292 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import com.palantir.timelock.config.TimeLockInstallConfiguration;
import com.palantir.timelock.corruption.detection.CorruptionHealthCheck;
import com.palantir.timelock.corruption.detection.LocalCorruptionDetector;
import com.palantir.timelock.corruption.detection.LocalTimestampInvariantsVerifier;
import com.palantir.timelock.corruption.detection.RemoteCorruptionDetector;
import com.palantir.timelock.history.LocalHistoryLoader;
import com.palantir.timelock.history.PaxosLogHistoryProvider;
Expand Down Expand Up @@ -254,10 +253,8 @@ private static TimeLockCorruptionComponents timeLockCorruptionComponents(
PaxosLogHistoryProvider historyProvider =
new PaxosLogHistoryProvider(dataSource, remoteClients.getRemoteHistoryProviders());

LocalTimestampInvariantsVerifier timestampInvariantsVerifier = new LocalTimestampInvariantsVerifier(dataSource);

LocalCorruptionDetector localCorruptionDetector = LocalCorruptionDetector.create(
historyProvider, remoteClients.getRemoteCorruptionNotifiers(), timestampInvariantsVerifier);
LocalCorruptionDetector localCorruptionDetector =
LocalCorruptionDetector.create(historyProvider, remoteClients.getRemoteCorruptionNotifiers());

CorruptionHealthCheck healthCheck =
new CorruptionHealthCheck(localCorruptionDetector, remoteCorruptionDetector);
Expand Down
1 change: 0 additions & 1 deletion timelock-corruption-detection/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ dependencies {
compile group: 'com.google.guava', name: 'guava'
compile group: 'com.github.rholder', name: 'guava-retrying'
compile group: 'com.palantir.conjure.java.api', name: 'service-config'
compile group: 'one.util', name: 'streamex'

annotationProcessor group: 'org.immutables', name: 'value'
compileOnly 'org.immutables:value::annotations'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
public enum CorruptionCheckViolation {
NONE(false, false),
DIVERGED_LEARNERS(true, false), // this is false for now
CLOCK_WENT_BACKWARDS(true, false), // this is false for now
VALUE_LEARNED_WITHOUT_QUORUM(true, false),
ACCEPTED_VALUE_GREATER_THAN_LEARNED(true, false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,43 +34,30 @@ public final class LocalCorruptionDetector implements CorruptionDetector {
new NamedThreadFactory(CORRUPTION_DETECTOR_THREAD_PREFIX, true));
private final LocalCorruptionHandler corruptionHandler;
private final PaxosLogHistoryProvider historyProvider;
private final LocalTimestampInvariantsVerifier timestampInvariantsVerifier;

private volatile CorruptionStatus localCorruptionState = CorruptionStatus.HEALTHY;
private volatile CorruptionHealthReport localCorruptionReport = CorruptionHealthReport.defaultHealthyReport();

public static LocalCorruptionDetector create(
PaxosLogHistoryProvider historyProvider,
List<TimeLockCorruptionNotifier> corruptionNotifiers,
LocalTimestampInvariantsVerifier timestampInvariants) {
PaxosLogHistoryProvider historyProvider, List<TimeLockCorruptionNotifier> corruptionNotifiers) {
LocalCorruptionDetector localCorruptionDetector =
new LocalCorruptionDetector(historyProvider, corruptionNotifiers, timestampInvariants);
new LocalCorruptionDetector(historyProvider, corruptionNotifiers);

localCorruptionDetector.scheduleWithFixedDelay();
return localCorruptionDetector;
}

private LocalCorruptionDetector(
PaxosLogHistoryProvider historyProvider,
List<TimeLockCorruptionNotifier> corruptionNotifiers,
LocalTimestampInvariantsVerifier timestampInvariantsVerifier) {
PaxosLogHistoryProvider historyProvider, List<TimeLockCorruptionNotifier> corruptionNotifiers) {

this.historyProvider = historyProvider;
this.timestampInvariantsVerifier = timestampInvariantsVerifier;
this.corruptionHandler = new LocalCorruptionHandler(corruptionNotifiers);
}

private void scheduleWithFixedDelay() {
executor.scheduleWithFixedDelay(
() -> {
CorruptionHealthReport paxosRoundCorruptionReport = analyzeHistoryAndBuildCorruptionHealthReport();
CorruptionHealthReport timestampInvariantsReport =
timestampInvariantsVerifier.timestampInvariantsHealthReport();
localCorruptionReport = ImmutableCorruptionHealthReport.builder()
.from(paxosRoundCorruptionReport)
.putAllViolatingStatusesToNamespaceAndUseCase(
timestampInvariantsReport.violatingStatusesToNamespaceAndUseCase())
.build();
localCorruptionReport = analyzeHistoryAndBuildCorruptionHealthReport();
processLocalHealthReport();
},
TIMELOCK_CORRUPTION_ANALYSIS_INTERVAL.getSeconds(),
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,6 @@ public LearnerAndAcceptorRecords getLearnerAndAcceptorLogsInRange(
querySequenceBounds.getUpperBoundInclusive())));
}

public Map<Long, PaxosValue> getLearnerLogsSince(
Client namespace, LearnerUseCase learnerUseCase, long lowerBoundInclusive, int learnerLogBatchSizeLimit) {
return execute(dao -> dao.getLearnerLogsSince(
namespace, learnerUseCase.value(), lowerBoundInclusive, learnerLogBatchSizeLimit));
}

public long getGreatestLogEntry(Client client, LearnerUseCase useCase) {
return executeSqlitePaxosStateLogQuery(dao -> dao.getGreatestLogEntry(client, useCase.value()))
.orElse(PaxosAcceptor.NO_LOG_ENTRY);
Expand All @@ -105,6 +99,11 @@ public interface Queries {
@SqlQuery("SELECT DISTINCT namespace, useCase FROM paxosLog")
Set<NamespaceAndUseCase> getAllNamespaceAndUseCaseTuples();

// TODO(snanda): For now, limit is based on approximation and has not been tested with remotes. We need
// to
// revisit this once we have the remote history providers set up. Also, we may have to make it
// configurable to
// accommodate the rate at which logs are being published.
@SqlQuery("SELECT seq, val FROM paxosLog WHERE namespace = :namespace.value AND useCase = :useCase AND seq >="
+ " :lowerBoundInclusive AND seq <= :upperBoundInclusive")
Map<Long, PaxosValue> getLearnerLogsInRange(
Expand All @@ -120,13 +119,5 @@ Map<Long, PaxosAcceptorData> getAcceptorLogsInRange(
@Bind("useCase") String useCase,
@Bind("lowerBoundInclusive") long lowerBoundInclusive,
@Bind("upperBoundInclusive") long upperBoundInclusive);

@SqlQuery("SELECT seq, val FROM paxosLog WHERE namespace = :namespace.value AND useCase = :useCase AND seq >="
+ " :lowerBoundInclusive ORDER BY seq ASC LIMIT :limit")
Map<Long, PaxosValue> getLearnerLogsSince(
@BindPojo("namespace") Client namespace,
@Bind("useCase") String useCase,
@Bind("lowerBoundInclusive") long lowerBoundInclusive,
@Bind("limit") long learnerLogBatchSizeLimit);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -105,31 +105,6 @@ List<StateLogComponents> createStatLogComponentsForNamespaceAndUseCase(Namespace
return timeLockCorruptionTestSetup.createStatLogForNamespaceAndUseCase(namespaceAndUseCase);
}

void assertClockGoesBackwardsInNextBatch() {
assertLocalTimestampInvariants(ImmutableSet.of(CorruptionCheckViolation.CLOCK_WENT_BACKWARDS));
}

void assertLocalTimestampInvariantsStandInNextBatch() {
assertLocalTimestampInvariants(ImmutableSet.of());
}

void createTimestampInversion(int round) {
PaxosSerializationTestUtils.writePaxosValue(
getDefaultLocalServer().learnerLog(),
round,
PaxosSerializationTestUtils.createPaxosValueForRoundAndData(round, round * 100));
}

private void assertLocalTimestampInvariants(Set<CorruptionCheckViolation> violations) {
CorruptionHealthReport corruptionHealthReport = timeLockCorruptionTestSetup
.getLocalTimestampInvariantsVerifier()
.timestampInvariantsHealthReport();
assertThat(corruptionHealthReport
.violatingStatusesToNamespaceAndUseCase()
.keySet())
.hasSameElementsAs(violations);
}

private static void writeLogsOnServer(StateLogComponents server, int startInclusive, int endInclusive) {
PaxosSerializationTestUtils.writeToLogs(
server.acceptorLog(), server.learnerLog(), startInclusive, endInclusive);
Expand Down
Loading

0 comments on commit 7f6c373

Please sign in to comment.