Copilot commented on code in PR #11346:
URL: https://github.com/apache/ozone/pull/11346#discussion_r4157071563
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMHADBTransactionBufferImpl.java:
##########
@@ -110,6 +110,26 @@ public SnapshotInfo getLatestSnapshot() {
return latestSnapshot.get();
}
+ @Override
+ public long getLatestSnapshotIndex() {
+ rwLock.readLock().lock();
+ try {
+ return latestSnapshot.get().getIndex();
Review Comment:
This is not necessarily the latest *flushed* index.
`SCMStateMachine.takeSnapshot()` calls `setLatestSnapshot(...)` at line 359
before `transactionBuffer.flush()` at line 364, so a scrape in that interval—or
after a failed flush—can expose an index that is not durable in the SCM DB.
Track a separate flushed watermark initialized from persisted transaction info
and advance it only after `commitBatchOperation` succeeds.
This issue also appears on line 124 of the same file.
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMHAMetrics.java:
##########
@@ -64,13 +76,22 @@ public static void unRegister() {
public synchronized void getMetrics(MetricsCollector collector, boolean all)
{
// Check current node state (1 leader, 0 follower)
int state = currNodeId.equals(leaderId) ? 1 : 0;
+ long latestSnapshotIndex = transactionBuffer == null ? -1
+ : transactionBuffer.getLatestSnapshotIndex();
+ long lastSnapshotTimeMs = transactionBuffer == null ? -1
+ : transactionBuffer.getLastSnapshotTimeMs();
Review Comment:
The index and timestamp are fetched under two separate read-lock
acquisitions, so a flush can complete between these calls and emit an old index
paired with the new flush time. Since the dashboard correlates these values as
one DB durability state, expose/read one immutable flush-state snapshot under a
single lock.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]