From 51f31aa136bd41ba5f27387956aa199cf2079398 Mon Sep 17 00:00:00 2001 From: blindchaser Date: Fri, 15 May 2026 18:48:22 -0400 Subject: [PATCH] fix(flatkv): correct catchup metrics: Avoid recording CurrentVersion from catchup so read-only historical loads do not pollute the write-mode height metric. Reset PendingWrites after each replayed WAL entry to mirror Commit behavior. --- sei-db/state_db/sc/flatkv/store_catchup.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sei-db/state_db/sc/flatkv/store_catchup.go b/sei-db/state_db/sc/flatkv/store_catchup.go index 8afdf481a1..dc3cdec058 100644 --- a/sei-db/state_db/sc/flatkv/store_catchup.go +++ b/sei-db/state_db/sc/flatkv/store_catchup.go @@ -100,10 +100,14 @@ func (s *CommitStore) catchup(targetVersion int64) (err error) { // Replayed blocks are reported regardless of catchup outcome: even on a // later error, the blocks that did replay are real progress that moved // committedVersion forward. + // + // CurrentVersion is intentionally NOT recorded here: the write-mode + // callers (LoadVersion, Rollback) record it on success themselves, and + // recording it from catchup would pollute the gauge when openReadOnly + // invokes catchup during a read-only historical load. defer func() { if replayed > 0 { otelMetrics.CatchupReplayNumBlocks.Add(s.ctx, int64(replayed)) - otelMetrics.CurrentVersion.Record(s.ctx, s.committedVersion) } obs.done(&err, nil, "startOffset", startOff, @@ -204,6 +208,10 @@ func (s *CommitStore) catchup(targetVersion int64) (err error) { s.committedVersion = entry.Version s.committedLtHash = s.workingLtHash.Clone() s.clearPendingWrites() + recordPendingWrites(s.ctx, accountDBDir, 0) + recordPendingWrites(s.ctx, codeDBDir, 0) + recordPendingWrites(s.ctx, storageDBDir, 0) + recordPendingWrites(s.ctx, legacyDBDir, 0) expectedNext = entry.Version + 1 replayed++