Skip to content

Commit ad220c1

Browse files
authored
Pass checkpoint to commit extra user data function (#122930)
Relates ES-10852
1 parent 04422cd commit ad220c1

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

server/src/main/java/org/elasticsearch/index/engine/InternalEngine.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2925,7 +2925,7 @@ protected void commitIndexWriter(final IndexWriter writer, final Translog transl
29252925
* {@link IndexWriter#commit()} call flushes all documents, we defer computation of the maximum sequence number to the time
29262926
* of invocation of the commit data iterator (which occurs after all documents have been flushed to Lucene).
29272927
*/
2928-
final Map<String, String> extraCommitUserData = getCommitExtraUserData();
2928+
final Map<String, String> extraCommitUserData = getCommitExtraUserData(localCheckpoint);
29292929
final Map<String, String> commitData = Maps.newMapWithExpectedSize(8 + extraCommitUserData.size());
29302930
commitData.putAll(extraCommitUserData);
29312931
commitData.put(Translog.TRANSLOG_UUID_KEY, translog.getTranslogUUID());
@@ -2973,8 +2973,10 @@ protected void commitIndexWriter(final IndexWriter writer, final Translog transl
29732973
/**
29742974
* Allows InternalEngine extenders to return custom key-value pairs which will be included in the Lucene commit user-data. Custom user
29752975
* data keys can be overwritten by if their keys conflict keys used by InternalEngine.
2976+
*
2977+
* @param localCheckpoint the local checkpoint of the commit
29762978
*/
2977-
protected Map<String, String> getCommitExtraUserData() {
2979+
protected Map<String, String> getCommitExtraUserData(final long localCheckpoint) {
29782980
return Collections.emptyMap();
29792981
}
29802982

server/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7327,7 +7327,7 @@ public void testExtraUserDataIsCommitted() throws IOException {
73277327
engine.close();
73287328
engine = new InternalEngine(engine.config()) {
73297329
@Override
7330-
protected Map<String, String> getCommitExtraUserData() {
7330+
protected Map<String, String> getCommitExtraUserData(final long localCheckpoint) {
73317331
return Map.of("userkey", "userdata", ES_VERSION, IndexVersions.ZERO.toString());
73327332
}
73337333
};

0 commit comments

Comments
 (0)