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

handle unexpected exception on success callback of translog upload #12577

Merged
Merged
Changes from 2 commits
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 @@ -8,6 +8,8 @@

package org.opensearch.index.translog.transfer;

import org.apache.logging.log4j.Logger;
import org.opensearch.common.logging.Loggers;
import org.opensearch.core.index.shard.ShardId;
import org.opensearch.index.remote.RemoteTranslogTransferTracker;
import org.opensearch.index.translog.transfer.FileSnapshot.TransferFileSnapshot;
Expand All @@ -33,11 +35,13 @@
private final RemoteTranslogTransferTracker remoteTranslogTransferTracker;
private Map<String, Long> bytesForTlogCkpFileToUpload;
private long fileTransferStartTime = -1;
private final Logger logger;

public FileTransferTracker(ShardId shardId, RemoteTranslogTransferTracker remoteTranslogTransferTracker) {
this.shardId = shardId;
this.fileTransferTracker = new ConcurrentHashMap<>();
this.remoteTranslogTransferTracker = remoteTranslogTransferTracker;
this.logger = Loggers.getLogger(getClass(), shardId);
}

void recordFileTransferStartTime(long uploadStartTime) {
Expand All @@ -64,10 +68,20 @@

@Override
public void onSuccess(TransferFileSnapshot fileSnapshot) {
long durationInMillis = (System.nanoTime() - fileTransferStartTime) / 1_000_000L;
remoteTranslogTransferTracker.addUploadTimeInMillis(durationInMillis);
remoteTranslogTransferTracker.addUploadBytesSucceeded(bytesForTlogCkpFileToUpload.get(fileSnapshot.getName()));
add(fileSnapshot.getName(), TransferState.SUCCESS);
try {
long durationInMillis = (System.nanoTime() - fileTransferStartTime) / 1_000_000L;
remoteTranslogTransferTracker.addUploadTimeInMillis(durationInMillis);
remoteTranslogTransferTracker.addUploadBytesSucceeded(bytesForTlogCkpFileToUpload.get(fileSnapshot.getName()));
sachinpkale marked this conversation as resolved.
Show resolved Hide resolved
} catch (Exception ex) {
logger.error("Failure to update translog upload success stats", ex);

Check warning on line 76 in server/src/main/java/org/opensearch/index/translog/transfer/FileTransferTracker.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/opensearch/index/translog/transfer/FileTransferTracker.java#L75-L76

Added lines #L75 - L76 were not covered by tests
}

try {
// add() gets a dedicated try/catch as its on the critical path
add(fileSnapshot.getName(), TransferState.SUCCESS);
} catch (IllegalStateException ex) {
throw new FileTransferException(fileSnapshot, ex);

Check warning on line 83 in server/src/main/java/org/opensearch/index/translog/transfer/FileTransferTracker.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/opensearch/index/translog/transfer/FileTransferTracker.java#L82-L83

Added lines #L82 - L83 were not covered by tests
}
}

void add(String file, boolean success) {
Expand Down
Loading