Skip to content

Refactor[mqbs::FileStore]: Rename d_primaryLeaseId to d_writeHeadLeaseId - #1660

Merged
kaikulimu merged 1 commit into
bloomberg:mainfrom
kaikulimu:d_writeHeadLeaseId
Jul 28, 2026
Merged

Refactor[mqbs::FileStore]: Rename d_primaryLeaseId to d_writeHeadLeaseId#1660
kaikulimu merged 1 commit into
bloomberg:mainfrom
kaikulimu:d_writeHeadLeaseId

Conversation

@kaikulimu

@kaikulimu kaikulimu commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Renames mqbs::FileStore::d_primaryLeaseId to d_writeHeadLeaseId to reflect what the member actually is.
  • The old name misleadingly suggested "the cluster-state primary's lease id." In reality it's the active write cursor's lease id — the lease id of the next record this store writes or applies, and the key for the current sequence number d_highestSeqNums[d_writeHeadLeaseId].
  • This is a storage-layer value derived from the journal at recovery and advanced as records are written/applied (or via setActivePrimary); it can differ transiently from the cluster's primary lease id (e.g. during recovery, or on a replica lagging the primary). The clearer name prevents that misreading.
  • Pure rename + doc clarification — no behavior change.

@kaikulimu
kaikulimu requested a review from 678098 July 28, 2026 19:03
@kaikulimu
kaikulimu requested a review from a team as a code owner July 28, 2026 19:03
/// value, not the cluster-state primary lease id; the two can differ
/// transiently (e.g. during recovery/conform, or on a replica lagging the
/// primary).
unsigned int d_writeHeadLeaseId;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In reality it's the write-head lease id — the lease id stamped on the next record this store writes or applies, paired with the sequence number d_highestSeqNums[d_writeHeadLeaseId].

If this is the next lease id, why not naming it d_nextWriteLeaseId?
I think that the PR's proposed name is less obvious than this.

Let's also update the docs to explicitly say if the currently stored lease id is written already or is it intended for the next write.

Comment thread src/groups/mqb/mqbs/mqbs_filestore.h Outdated
/// Lease id of the current primary. The current sequence number is
/// always `d_highestSeqNums[d_primaryLeaseId]`.
unsigned int d_primaryLeaseId;
/// Lease id stamped on the next record this store writes or applies (the

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stamped - personally I don't like the complete form of action, if it is not stamped yet.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd push back on d_nextWriteLeaseId. Its partner sequenceNumber() returns the highest/last seq already written under this lease, not the next — and the pair (d_writeHeadLeaseId, sequenceNumber()) is logged everywhere as the current/self PSN, i.e. the position already reached. Naming the lease "next" while its seq half is "last" makes the two halves of the same PSN contradict each other.

"Write head" (a cursor) fits both: it sits at the last written position and is where the next write lands. "next" only names half of that.

Comment thread src/groups/mqb/mqbs/mqbs_filestore.h Outdated
/// "write head"; current sequence number is
/// `d_highestSeqNums[d_writeHeadLeaseId]`). This is a storage-layer
/// value, not the cluster-state primary lease id; the two can differ
/// transiently (e.g. during recovery/conform, or on a replica lagging the

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not the cluster-state primary lease id; the two can differ
    /// transiently (e.g. during recovery/conform, or on a replica lagging the

A general comment, I think the docs should describe what something is, not what something isn't

Signed-off-by: Yuan Jing Vincent Yan <yyan82@bloomberg.net>
@kaikulimu
kaikulimu force-pushed the d_writeHeadLeaseId branch from d676d66 to b349510 Compare July 28, 2026 20:49
@678098 678098 assigned kaikulimu and unassigned 678098 Jul 28, 2026
@kaikulimu kaikulimu closed this Jul 28, 2026
@kaikulimu
kaikulimu deleted the d_writeHeadLeaseId branch July 28, 2026 21:24
@kaikulimu
kaikulimu restored the d_writeHeadLeaseId branch July 28, 2026 21:26
@kaikulimu kaikulimu reopened this Jul 28, 2026
@kaikulimu
kaikulimu merged commit b80e22d into bloomberg:main Jul 28, 2026
104 of 106 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants