Skip to content

Commit

Permalink
Ignore first revision when reinitialising S3 state store
Browse files Browse the repository at this point in the history
  • Loading branch information
kr565370 committed Sep 28, 2023
1 parent a2473d5 commit 0547572
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
import java.util.stream.Collectors;

import static sleeper.statestore.s3.S3RevisionUtils.RevisionId;
import static sleeper.statestore.s3.S3StateStore.FIRST_REVISION;

public class S3FileInfoStore implements FileInfoStore {
private static final Logger LOGGER = LoggerFactory.getLogger(S3FileInfoStore.class);
Expand Down Expand Up @@ -422,7 +423,7 @@ private Schema initialiseFileInfoSchema() {
}

public void initialise() throws StateStoreException {
RevisionId firstRevisionId = new RevisionId(S3StateStore.getZeroPaddedLong(1L), UUID.randomUUID().toString());
RevisionId firstRevisionId = new RevisionId(FIRST_REVISION, UUID.randomUUID().toString());
String path = getFilesPath(firstRevisionId);
try {
writeFileInfosToParquet(Collections.emptyList(), path);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
import java.util.stream.Collectors;

import static sleeper.statestore.s3.S3RevisionUtils.RevisionId;
import static sleeper.statestore.s3.S3StateStore.getZeroPaddedLong;
import static sleeper.statestore.s3.S3StateStore.FIRST_REVISION;

public class S3PartitionStore implements PartitionStore {
private static final Logger LOGGER = LoggerFactory.getLogger(S3PartitionStore.class);
Expand Down Expand Up @@ -254,13 +254,12 @@ public void initialise(List<Partition> partitions) throws StateStoreException {
private void setPartitions(List<Partition> partitions) throws StateStoreException {
// Validate that there is no current revision id
RevisionId oldRevisionId = s3RevisionUtils.getCurrentPartitionsRevisionId();
if (null != oldRevisionId) {
if (null != oldRevisionId && !oldRevisionId.getRevision().equals(FIRST_REVISION)) {
throw new StateStoreException("Dynamo should not contain current revision id; found " + oldRevisionId);
}

// Write partitions to file
long version = 1L;
String versionString = getZeroPaddedLong(version);
String versionString = FIRST_REVISION;
RevisionId revisionId = new RevisionId(versionString, UUID.randomUUID().toString());
String path = getPartitionsPath(revisionId);
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public class S3StateStore extends DelegatingStateStore {
public static final String CURRENT_FILES_REVISION_ID_KEY = "CURRENT_FILES_REVISION_ID_KEY";
public static final String CURRENT_REVISION = "CURRENT_REVISION";
public static final String CURRENT_UUID = "CURRENT_UUID";
public static final String FIRST_REVISION = S3StateStore.getZeroPaddedLong(1L);

public S3StateStore(InstanceProperties instanceProperties,
TableProperties tableProperties,
Expand Down

0 comments on commit 0547572

Please sign in to comment.