refactor: Remove timeSrc from QueueStore#7735
refactor: Remove timeSrc from QueueStore#7735natemort merged 1 commit intocadence-workflow:masterfrom
Conversation
…ion in queue write/ack paths via ensureQueueMetadata Signed-off-by: Stanislav Bychkov <stanislb@netapp.com>
| if queueMetadata == nil { | ||
| return nil, insertErr | ||
| } | ||
| } else { |
There was a problem hiding this comment.
💡 Performance: Redundant re-read after successful metadata insert
In ensureQueueMetadata, after a successful insertInitialQueueMetadataRecord (line 85-94), the code re-reads the metadata from the database with getQueueMetadata. Since we just successfully inserted it, the metadata state is known — we could construct the QueueMetadataRow directly from the values we just inserted (version 0, empty ClusterAckLevels, the provided currentTimestamp) instead of making another round-trip to the database.
This is a very minor concern since it only happens once per queue lifetime (on first initialization), but it does add an unnecessary database read on the happy path.
Suggested fix:
} else {
queueMetadata = &nosqlplugin.QueueMetadataRow{
QueueType: queueType,
Version: 0,
ClusterAckLevels: map[string]int64{},
CurrentTimeStamp: currentTimestamp,
}
}
Was this helpful? React with 👍 / 👎
There was a problem hiding this comment.
I prefer to re-read after insert so to return the authentic row, not a hand-made struct. It also guards against false positive cases in insertInitialQueueMetadataRecord.
And it has been said: cost is negligible since this runs only once during metadata initialization.
Code Review 👍 Approved with suggestions 0 resolved / 1 findingsClean refactoring that correctly removes timeSrc from the store layer and introduces well-structured lazy metadata initialization with proper concurrency handling. One minor suggestion to avoid a redundant database read after successful insert. 💡 Performance: Redundant re-read after successful metadata insert📄 common/persistence/nosql/nosql_queue_store.go:85 In This is a very minor concern since it only happens once per queue lifetime (on first initialization), but it does add an unnecessary database read on the happy path. Suggested fixRules ❌ No requirements metRepository Rules
1 rule not applicable. Show all rules by commenting OptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change:
Was this helpful? React with 👍 / 👎 | Gitar |
What changed?
Removed timeSrc from QueueStore. Added lazy metadata initializaion.
Why?
#6610
#6646 (comment)
The queue metadata was initialized too early, during newNoSQLQueueStore construction, before the manager layer existed, so the store had to generate time itself. This violated the goal of having all time generation happen at the persistence manager layer.
The fix defer metadata creation to the first operation that naturally carries a timestamp from the manager, instead of initializing it at construction time.
How did you test it?
unit test:
go test ./common/persistence/nosql -vintegrated test: Started local server and run
make test_e2ePotential risks
No risk changes
Release notes
Documentation Changes
Reviewer Validation
PR Description Quality (check these before reviewing code):
go testinvocation)