Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

db: avoid acquiring DB.mu during batch commit, unless rotating memtable #3602

Merged
merged 3 commits into from
May 13, 2024

Commits on May 13, 2024

  1. db: move log bytes-in to an atomic

    Move the log bytes-in metric out of the protection of db.mu and into an atomic.
    jbowens committed May 13, 2024
    Configuration menu
    Copy the full SHA
    58d8c09 View commit details
    Browse the repository at this point in the history
  2. db: avoid acquiring DB.mu during batch commit, unless rotating memtable

    Previously, DB.commitWrite would acquire the DB.mu before calling
    makeRoomForWrite to ensure the current memtable had sufficient space for the
    batch's contents. When DB.commitWrite is called, the caller already holds the
    commit pipeline's mutex providing mutual exclusion with other committers and,
    crucially, preventing the concurrent rotation of the memtable.
    
    This commit adjusts DB.commitWrite to attempt reserving space in the current
    mutable memtable before acquiring DB.mu. In the common case, if successful,
    there is no need to acquire DB.mu. If unsuccessful, the committer falls back to
    acuqiring DB.mu and rotating the memtable through calling makeRoomForWrite.
    
    Close cockroachdb#2680.
    jbowens committed May 13, 2024
    Configuration menu
    Copy the full SHA
    7d63c4c View commit details
    Browse the repository at this point in the history
  3. db: simplify makeRoomForWrite

    Refactor makeRoomForWrite to take advantage of the fact that it is now only
    called with a non-nil Batch when the current mutable memtable is known to have
    insufficient available space to index the Batch.
    jbowens committed May 13, 2024
    Configuration menu
    Copy the full SHA
    5aa2a4c View commit details
    Browse the repository at this point in the history