-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[Remote Translog] Trimming based on remote segment upload and cleaning older tlog files #5662
Changes from all commits
54c2989
c12708d
b6ee694
904c556
6a68c12
3186594
ee4f238
b6d72e3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,8 @@ public class RemoteFsTranslog extends Translog { | |
private final FileTransferTracker fileTransferTracker; | ||
private volatile long maxRemoteTranslogGenerationUploaded; | ||
|
||
private volatile long minSeqNoToKeep; | ||
|
||
public RemoteFsTranslog( | ||
TranslogConfig config, | ||
String translogUUID, | ||
|
@@ -282,4 +284,42 @@ public void close() throws IOException { | |
} | ||
} | ||
} | ||
|
||
protected long getMinReferencedGen() throws IOException { | ||
assert readLock.isHeldByCurrentThread() || writeLock.isHeldByCurrentThread(); | ||
long minReferencedGen = Math.min( | ||
deletionPolicy.minTranslogGenRequired(readers, current), | ||
minGenerationForSeqNo(Math.min(deletionPolicy.getLocalCheckpointOfSafeCommit() + 1, minSeqNoToKeep), current, readers) | ||
); | ||
assert minReferencedGen >= getMinFileGeneration() : "deletion policy requires a minReferenceGen of [" | ||
+ minReferencedGen | ||
+ "] but the lowest gen available is [" | ||
+ getMinFileGeneration() | ||
+ "]"; | ||
assert minReferencedGen <= currentFileGeneration() : "deletion policy requires a minReferenceGen of [" | ||
+ minReferencedGen | ||
+ "] which is higher than the current generation [" | ||
+ currentFileGeneration() | ||
+ "]"; | ||
return minReferencedGen; | ||
} | ||
|
||
protected void setMinSeqNoToKeep(long seqNo) { | ||
if (seqNo < this.minSeqNoToKeep) { | ||
throw new IllegalArgumentException( | ||
"min seq number required can't go backwards: " + "current [" + this.minSeqNoToKeep + "] new [" + seqNo + "]" | ||
); | ||
} | ||
this.minSeqNoToKeep = seqNo; | ||
Comment on lines
+307
to
+313
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For my understanding min should be able to go lower right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, once it is set to |
||
} | ||
|
||
@Override | ||
void deleteReaderFiles(TranslogReader reader) { | ||
gbbafna marked this conversation as resolved.
Show resolved
Hide resolved
|
||
try { | ||
translogTransferManager.deleteTranslog(primaryTermSupplier.getAsLong(), reader.generation); | ||
} catch (IOException ignored) { | ||
logger.error("Exception {} while deleting generation {}", ignored, reader.generation); | ||
} | ||
super.deleteReaderFiles(reader); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If delete in remote fails, do we still want to delete local files? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, we don't want to hold on to local files and filling the disk. We can have a background thread however to clean up the crumbs left here and also have stats around this. I will create an issue and update here. |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -194,4 +194,15 @@ private TransferFileSnapshot prepareMetadata(TransferSnapshot transferSnapshot) | |
translogTransferMetadata.getPrimaryTerm() | ||
); | ||
} | ||
|
||
public void deleteTranslog(long primaryTerm, long generation) throws IOException { | ||
String ckpFileName = Translog.getCommitCheckpointFileName(generation); | ||
String translogFilename = Translog.getFilename(generation); | ||
// ToDo - Take care of metadata file cleanup | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Created a backlog issue : #5677 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we really need to be tracking checkpoint files or only translog files, since we only care about the latest checkpoint? |
||
// https://github.com/opensearch-project/OpenSearch/issues/5677 | ||
fileTransferTracker.onDelete(ckpFileName); | ||
fileTransferTracker.onDelete(translogFilename); | ||
List<String> files = List.of(ckpFileName, translogFilename); | ||
transferService.deleteBlobs(remoteBaseTransferPath.add(String.valueOf(primaryTerm)), files); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default value of 0 should be good when
minSeqNoToKeep
has not been set ever?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could there be a case when a replica-primary promotion has happened and this has not been initialised or primary-primary relocation (peer recovery) in which case this can be problematic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In worst case, the default value of 0 would prevent further truncations. There would be some assertion failures , which would be disabled in prod.