Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Excavator: Upgrades Baseline to the latest version #6470

Merged
merged 11 commits into from
Sep 7, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ private InDbTimestampBoundStore(
this.physicalBoundStoreStrategy = physicalBoundStoreStrategy;
}

@SuppressWarnings("GuardedBy") // TODO (jkong): synchronize?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems odd and scary to suppress. I think we want something like the following instead:

    private volatile DBType dbType;
    private DBType getDbType(Connection connection) {
        DBType type = this.dbType; // volatile read
        if (type == null) {
            synchronized (this) {
                type = this.dbType;
                if (type == null) {
                    type = ConnectionDbTypes.getDbType(connection);
                    this.dbType = type;
                }
            }
        }
        return type;
    }

private void init() {
try (Connection conn = connManager.getConnection()) {
physicalBoundStoreStrategy.createTimestampTable(conn, this::getDbType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,15 +198,15 @@ private synchronized void processCommitUpdate(long startTimestamp) {
/**
* In order to maintain the necessary invariants, we need to do the following:
* <p>
* 1. For each new event, we apply it to the cache. The effects of this application is described in
* {@link LockWatchValueScopingCache}.
* 2. For each transaction, we must ensure that we store a snapshot of the cache at the sequence corresponding
* to the transaction's start timestamp. Note that not every sequence will have a corresponding timestamp, so we
* don't bother storing a snapshot for those sequences. Also note that we know that each call here will only
* ever have new events, and that consecutive calls to this method will *always* have increasing sequences
* (without this last guarantee, we'd need to store snapshots for all sequences).
* 3. For each transaction, we must create a transaction scoped cache. We do this now as we have tighter guarantees
* around when the cache is created, and thus deleted.
* 1. For each new event, we apply it to the cache. The effects of this application is described in
* {@link LockWatchValueScopingCache}.
* 2. For each transaction, we must ensure that we store a snapshot of the cache at the sequence corresponding
* to the transaction's start timestamp. Note that not every sequence will have a corresponding timestamp, so we
* don't bother storing a snapshot for those sequences. Also note that we know that each call here will only
* ever have new events, and that consecutive calls to this method will *always* have increasing sequences
* (without this last guarantee, we'd need to store snapshots for all sequences).
* 3. For each transaction, we must create a transaction scoped cache. We do this now as we have tighter guarantees
* around when the cache is created, and thus deleted.
*/
private synchronized void updateStores(TransactionsLockWatchUpdate updateForTransactions) {
Multimap<Sequence, StartTimestamp> reversedMap = createSequenceTimestampMultimap(updateForTransactions);
Expand Down Expand Up @@ -244,6 +244,7 @@ private synchronized boolean isNewEvent(LockWatchEvent event) {
.orElse(true);
}

@SuppressWarnings("GuardedBy") // The stream operation is terminal within this synchronized method.
private synchronized void assertNoSnapshotsMissing(Multimap<Sequence, StartTimestamp> reversedMap) {
Set<Sequence> sequences = reversedMap.keySet();
if (sequences.stream().map(snapshotStore::getSnapshotForSequence).anyMatch(Optional::isEmpty)) {
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ buildscript {
dependencies {
classpath 'com.netflix.nebula:gradle-info-plugin:12.1.6'
classpath 'com.netflix.nebula:nebula-publishing-plugin:20.3.0'
classpath 'com.palantir.baseline:gradle-baseline-java:4.188.0'
classpath 'com.palantir.baseline:gradle-baseline-java:5.0.0'
classpath 'com.palantir.gradle.conjure:gradle-conjure:5.41.0'
classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:2.13.0'
classpath 'com.palantir.gradle.docker:gradle-docker:0.32.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ public boolean unlockAndFreeze(HeldLocksToken token) {
}

@Override
@SuppressWarnings("checkstyle:NoFinalizer") // TODO (jkong): Can we safely remove this without breaking things?
@SuppressWarnings({"checkstyle:NoFinalizer", "Finalize"}) // TODO (jkong): Can we safely remove this without
// breaking things?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should migrate any finalize() to JDK Cleaner APIs as finalizer is deprecated in JDK 18 per JEP 421 and will be removed in the future. See also https://bugs.openjdk.org/browse/JDK-8253568

protected void finalize() throws Throwable {
super.finalize();
if (!isClosed) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ private void refreshLocks() {
}

@Override
@SuppressWarnings("checkstyle:NoFinalizer") // TODO (jkong): Can we safely remove this without breaking things?
@SuppressWarnings({"checkstyle:NoFinalizer", "Finalize"})
// TODO (jkong): Can we safely remove this without breaking things?
protected void finalize() throws Throwable {
super.finalize();
if (!isClosed) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ ObfuscatedLockDescriptor getDescriptorMapping(LockDescriptor descriptor) {
}

/**
*
* @return map from mapping to real descriptor.
* Return a map from mapping to real descriptor.
*/
Map<ObfuscatedLockDescriptor, LockDescriptor> getReversedMapper() {
return mapper.entrySet().stream().collect(Collectors.toMap(Map.Entry::getValue, Map.Entry::getKey));
Expand Down