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

Log more info with max seq no on upload to and download from remote translog #10973

Merged
merged 4 commits into from
Oct 30, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ public RemoteFsTranslog(
try {
download(translogTransferManager, location, logger);
Checkpoint checkpoint = readCheckpoint(location);
logger.info("Downloaded data from remote translog till maxSeqNo = {}", checkpoint.maxSeqNo);
this.readers.addAll(recoverFromFiles(checkpoint));
if (readers.isEmpty()) {
String errorMsg = String.format(Locale.ROOT, "%s at least one reader must be recovered", shardId);
Expand Down Expand Up @@ -266,9 +267,11 @@ public void rollGeneration() throws IOException {
}

private boolean prepareAndUpload(Long primaryTerm, Long generation) throws IOException {
long maxSeqNo = -1;
try (Releasable ignored = writeLock.acquire()) {
if (generation == null || generation == current.getGeneration()) {
try {
maxSeqNo = getMaxSeqNo();
final TranslogReader reader = current.closeIntoReader();
readers.add(reader);
copyCheckpointTo(location.resolve(getCommitCheckpointFileName(current.getGeneration())));
Expand Down Expand Up @@ -300,17 +303,17 @@ private boolean prepareAndUpload(Long primaryTerm, Long generation) throws IOExc
// is not updated in remote translog except in primary to primary recovery.
if (generation == null) {
if (closed.get() == false) {
return upload(primaryTerm, current.getGeneration() - 1);
return upload(primaryTerm, current.getGeneration() - 1, maxSeqNo);
} else {
return upload(primaryTerm, current.getGeneration());
return upload(primaryTerm, current.getGeneration(), maxSeqNo);
}
} else {
return upload(primaryTerm, generation);
return upload(primaryTerm, generation, maxSeqNo);
}
}
}

private boolean upload(Long primaryTerm, Long generation) throws IOException {
private boolean upload(long primaryTerm, long generation, long maxSeqNo) throws IOException {
// During primary relocation (primary-primary peer recovery), both the old and the new primary have engine
// created with the RemoteFsTranslog. Both primaries are equipped to upload the translogs. The primary mode check
// below ensures that the real primary only is uploading. Before the primary mode is set as true for the new
Expand All @@ -334,7 +337,7 @@ private boolean upload(Long primaryTerm, Long generation) throws IOException {
) {
return translogTransferManager.transferSnapshot(
transferSnapshotProvider,
new RemoteFsTranslogTransferListener(generation, primaryTerm)
new RemoteFsTranslogTransferListener(generation, primaryTerm, maxSeqNo)
);
}

Expand Down Expand Up @@ -522,23 +525,26 @@ private class RemoteFsTranslogTransferListener implements TranslogTransferListen
/**
* Generation for the translog
*/
private final Long generation;
private final long generation;

/**
* Primary Term for the translog
*/
private final Long primaryTerm;
private final long primaryTerm;

RemoteFsTranslogTransferListener(Long generation, Long primaryTerm) {
private final long maxSeqNo;

RemoteFsTranslogTransferListener(long generation, long primaryTerm, long maxSeqNo) {
this.generation = generation;
this.primaryTerm = primaryTerm;
this.maxSeqNo = maxSeqNo;
}

@Override
public void onUploadComplete(TransferSnapshot transferSnapshot) throws IOException {
maxRemoteTranslogGenerationUploaded = generation;
minRemoteGenReferenced = getMinFileGeneration();
logger.trace("uploaded translog for {} {} ", primaryTerm, generation);
logger.info("Successfully uploaded translog for primary term = {}, generation = {}, maxSeqNo = {}", primaryTerm, generation, maxSeqNo);
sachinpkale marked this conversation as resolved.
Show resolved Hide resolved
}

@Override
Expand Down
Loading