Pass checkpoint to commit extra user data function (#122930)

Relates ES-10852
This commit is contained in:
Iraklis Psaroudakis 2025-02-19 16:12:50 +02:00 committed by GitHub
parent 04422cdc7f
commit ad220c1abb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 3 deletions

View file

@ -2925,7 +2925,7 @@ public class InternalEngine extends Engine {
* {@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());
@ -2973,8 +2973,10 @@ public class InternalEngine extends Engine {
/**
* 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();
}

View file

@ -7327,7 +7327,7 @@ public class InternalEngineTests extends EngineTestCase {
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());
}
};