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

add static method to load store header #2097

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

pengpeng-lu
Copy link
Contributor

@pengpeng-lu pengpeng-lu commented Apr 18, 2023

Add this static method to load store header without opening the store.

@foundationdb-ci
Copy link
Contributor

Result of fdb-record-layer-pr-proto3 on Linux CentOS 7

  • Commit ID: 115ef63
  • Duration 0:15:06
  • Result: ❌ FAILED
  • Error: Error while executing command: ./gradlew --no-daemon --console=plain -b ./build.gradle build destructiveTest sonarqube -PcoreNotStrict -PreleaseBuild=false -PpublishBuild=false -PspotbugsEnableHtmlReport. Reason: exit status 1
  • Build Log terminal output (available for 30 days)
  • Build Workspace zip file of the working directory (available for 30 days)

@foundationdb-ci
Copy link
Contributor

Result of fdb-record-layer-pr-proto2 on Linux CentOS 7

  • Commit ID: 115ef63
  • Duration 0:16:02
  • Result: ❌ FAILED
  • Error: Error while executing command: ./gradlew --no-daemon --console=plain -b ./build.gradle build destructiveTest sonarqube -PcoreNotStrict -PreleaseBuild=false -PpublishBuild=false -PspotbugsEnableHtmlReport. Reason: exit status 1
  • Build Log terminal output (available for 30 days)
  • Build Workspace zip file of the working directory (available for 30 days)

@sonarcloud
Copy link

sonarcloud bot commented Apr 20, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 2 Code Smells

0.0% 0.0% Coverage
28.3% 28.3% Duplication

@foundationdb-ci
Copy link
Contributor

Result of fdb-record-layer-pr-proto3 on Linux CentOS 7

  • Commit ID: 7820699
  • Duration 0:18:05
  • Result: ✅ SUCCEEDED
  • Error: N/A
  • Build Log terminal output (available for 30 days)
  • Build Workspace zip file of the working directory (available for 30 days)

@foundationdb-ci
Copy link
Contributor

Result of fdb-record-layer-pr-proto2 on Linux CentOS 7

  • Commit ID: 7820699
  • Duration 1:00:47
  • Result: ❌ FAILED
  • Error: Build has timed out.
  • Build Log terminal output (available for 30 days)
  • Build Workspace zip file of the working directory (available for 30 days)

@@ -2107,6 +2107,30 @@ private CompletableFuture<Void> checkUserVersion(@Nullable UserVersionChecker us
});
}

private static RecordMetaDataProto.DataStoreInfo checkAndParseStoreHeader(@Nullable KeyValue firstKeyValue,
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of duplicating this method, the non-static version should call this version

Comment on lines +2408 to +2410
SubspaceProvider subspaceProvider1 = new SubspaceProviderByKeySpacePath(keySpacePath);
Subspace subspace1 = subspaceProvider1.getSubspace(context);
return readStoreFirstKey(context, subspace1, IsolationLevel.SERIALIZABLE).thenApply(keyValue -> checkAndParseStoreHeader(keyValue, StoreExistenceCheck.NONE, context, subspaceProvider1, subspace1));
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
SubspaceProvider subspaceProvider1 = new SubspaceProviderByKeySpacePath(keySpacePath);
Subspace subspace1 = subspaceProvider1.getSubspace(context);
return readStoreFirstKey(context, subspace1, IsolationLevel.SERIALIZABLE).thenApply(keyValue -> checkAndParseStoreHeader(keyValue, StoreExistenceCheck.NONE, context, subspaceProvider1, subspace1));
SubspaceProvider subspaceProvider = new SubspaceProviderByKeySpacePath(keySpacePath);
Subspace subspace = subspaceProvider.getSubspace(context);
return readStoreFirstKey(context, subspace, IsolationLevel.SERIALIZABLE).thenApply(keyValue -> checkAndParseStoreHeader(keyValue, StoreExistenceCheck.NONE, context, subspaceProvider, subspace));

Comment on lines +2408 to +2410
SubspaceProvider subspaceProvider1 = new SubspaceProviderByKeySpacePath(keySpacePath);
Subspace subspace1 = subspaceProvider1.getSubspace(context);
return readStoreFirstKey(context, subspace1, IsolationLevel.SERIALIZABLE).thenApply(keyValue -> checkAndParseStoreHeader(keyValue, StoreExistenceCheck.NONE, context, subspaceProvider1, subspace1));
Copy link
Contributor

Choose a reason for hiding this comment

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

If this takes the StoreExistenceCheck as a parameter, acn more of this be shared between the static and non-static version of loadStoreHeaderAsync

@@ -2380,6 +2404,12 @@ private void endRecordStoreStateWrite() {
});
}

public static CompletableFuture<RecordMetaDataProto.DataStoreInfo> loadStoreHeaderAsync(@Nonnull FDBRecordContext context, @Nonnull KeySpacePath keySpacePath) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This should have a javadoc
It should probably also be marked as INTERNAL.

@@ -2380,6 +2404,12 @@ private void endRecordStoreStateWrite() {
});
}

public static CompletableFuture<RecordMetaDataProto.DataStoreInfo> loadStoreHeaderAsync(@Nonnull FDBRecordContext context, @Nonnull KeySpacePath keySpacePath) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This change should come with a github issue, and an update to the release notes

@@ -3237,6 +3267,49 @@ private CompletableFuture<RecordStoreState> loadRecordStoreStateInternalAsync(@N
return context.instrument(FDBStoreTimer.Events.LOAD_RECORD_STORE_STATE, storeHeaderFuture.thenCombine(loadIndexStates, RecordStoreState::new));
}

@Nonnull
@SuppressWarnings("PMD.CloseResource")
public static CompletableFuture<Map<String, IndexState>> loadIndexStatesAsync(@Nonnull Subspace subspace, @Nonnull FDBRecordContext context) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be better to have the non-static version call this version, and remove the duplication of logic here.
Also, this method should have a javadoc and probably be marked as INTERNAL

Copy link
Contributor

Choose a reason for hiding this comment

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

Particularly of note for the javadoc is that readable indexes are not included in the returned map

@@ -209,6 +210,24 @@ public void prefixPrimaryKeysWithNullByteAfterPrefix(int formatVersion, boolean
}
}

@Test
public void testLoadStoreHeader() throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

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

There should also be a test for loading the index statuses

RecordMetaDataProto.DataStoreInfo dataStoreInfo1 = FDBRecordStore.loadStoreHeaderAsync(context, path).get();
// load store header with old method
RecordMetaDataProto.DataStoreInfo dataStoreInfo2 = recordStore.getRecordStoreState().getStoreHeader();
// assert
Copy link
Contributor

Choose a reason for hiding this comment

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

RecordMetaDataProto.DataStoreInfo is a protobuf so it would be better to just assert that the two datastoreInfos are equals, so that this test maintains coverage if those protobuf definitions add fields.

Assertions.assertEquals(FDBRecordStore.MAX_SUPPORTED_FORMAT_VERSION, dataStoreInfo2.getFormatVersion());
Assertions.assertEquals(recordStore.getRecordMetaData().getVersion(), dataStoreInfo1.getMetaDataversion());
Assertions.assertEquals(recordStore.getRecordMetaData().getVersion(), dataStoreInfo2.getMetaDataversion());
Assertions.assertEquals(dataStoreInfo1.getLastUpdateTime(), dataStoreInfo2.getLastUpdateTime());
Copy link
Contributor

Choose a reason for hiding this comment

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

It's probably overkill, but it might be good to change the store header and assert that getting it still gets the same value.
Perhaps more relevant for getting the index states than the store header

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants