Skip to content

Commit

Permalink
Pass checkpoint to commit extra user data function (#122930)
Browse files Browse the repository at this point in the history
Relates ES-10852
  • Loading branch information
kingherc authored Feb 19, 2025
1 parent 04422cd commit ad220c1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2925,7 +2925,7 @@ protected void commitIndexWriter(final IndexWriter writer, final Translog transl
* {@link IndexWriter#commit()} call flushes all documents, we defer computation of the maximum sequence number to the time
* of invocation of the commit data iterator (which occurs after all documents have been flushed to Lucene).
*/
final Map<String, String> extraCommitUserData = getCommitExtraUserData();
final Map<String, String> extraCommitUserData = getCommitExtraUserData(localCheckpoint);
final Map<String, String> commitData = Maps.newMapWithExpectedSize(8 + extraCommitUserData.size());
commitData.putAll(extraCommitUserData);
commitData.put(Translog.TRANSLOG_UUID_KEY, translog.getTranslogUUID());
Expand Down Expand Up @@ -2973,8 +2973,10 @@ protected void commitIndexWriter(final IndexWriter writer, final Translog transl
/**
* Allows InternalEngine extenders to return custom key-value pairs which will be included in the Lucene commit user-data. Custom user
* data keys can be overwritten by if their keys conflict keys used by InternalEngine.
*
* @param localCheckpoint the local checkpoint of the commit
*/
protected Map<String, String> getCommitExtraUserData() {
protected Map<String, String> getCommitExtraUserData(final long localCheckpoint) {
return Collections.emptyMap();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7327,7 +7327,7 @@ public void testExtraUserDataIsCommitted() throws IOException {
engine.close();
engine = new InternalEngine(engine.config()) {
@Override
protected Map<String, String> getCommitExtraUserData() {
protected Map<String, String> getCommitExtraUserData(final long localCheckpoint) {
return Map.of("userkey", "userdata", ES_VERSION, IndexVersions.ZERO.toString());
}
};
Expand Down

0 comments on commit ad220c1

Please sign in to comment.