From 53c6d33b0c2e612aff1352a8f237ee6e83cdfe42 Mon Sep 17 00:00:00 2001
From: Valery Kharseko <vharseko@3a-systems.ru>
Date: Wed, 21 Oct 2026 07:00:50 +0000
Subject: [PATCH] [#1227] Keep the record a changelog cursor read in advance when the head log file it is positioned in is rotated (#1228)
---
opendj-server-legacy/src/main/java/org/opends/server/replication/server/changelog/file/LogFile.java | 27 ++++++++++++++++++++++-----
1 files changed, 22 insertions(+), 5 deletions(-)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/replication/server/changelog/file/LogFile.java b/opendj-server-legacy/src/main/java/org/opends/server/replication/server/changelog/file/LogFile.java
index 299ca53..8704c2b 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/replication/server/changelog/file/LogFile.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/replication/server/changelog/file/LogFile.java
@@ -368,15 +368,19 @@
*
* @param record
* The initial record this cursor points on
+ * @param initialRecord
+ * The record the cursor read in advance, which it returns before it reads at the
+ * provided position, or {@code null} if there is none
* @param position
* The file position this cursor points on
* @return the cursor
* @throws ChangelogException
* If a problem occurs while creating the cursor.
*/
- LogFileCursor<K, V> getCursorInitialisedTo(Record<K,V> record, long position) throws ChangelogException
+ LogFileCursor<K, V> getCursorInitialisedTo(Record<K,V> record, Record<K, V> initialRecord, long position)
+ throws ChangelogException
{
- return new LogFileCursor<>(this, record, position);
+ return new LogFileCursor<>(this, record, initialRecord, position);
}
/**
@@ -583,17 +587,19 @@
}
/**
- * Creates a cursor on the provided log, initialised to the provided record and
+ * Creates a cursor on the provided log, initialised to the provided records and
* pointing to the provided file position.
* <p>
- * Note: there is no check to ensure that provided record and file position are
+ * Note: there is no check to ensure that provided records and file position are
* consistent. It is the responsibility of the caller of this method.
*/
- private LogFileCursor(LogFile<K, V> logFile, Record<K, V> record, long filePosition) throws ChangelogException
+ private LogFileCursor(LogFile<K, V> logFile, Record<K, V> record, Record<K, V> initialRecord, long filePosition)
+ throws ChangelogException
{
this.logFile = logFile;
this.reader = logFile.getReader();
this.currentRecord = record;
+ this.initialRecord = initialRecord;
logFile.sharedLock.lock();
try
{
@@ -635,6 +641,17 @@
return currentRecord;
}
+ /**
+ * Returns the record this cursor read in advance when it was positioned, which the next call
+ * to {@link #next()} returns before anything is read from the file.
+ *
+ * @return the record read in advance, or {@code null} if there is none
+ */
+ Record<K, V> getInitialRecord()
+ {
+ return initialRecord;
+ }
+
/** {@inheritDoc} */
@Override
public boolean positionTo(final K key, final KeyMatchingStrategy match, final PositionStrategy pos)
--
Gitblit v1.10.0