Skip to content

Lock fingerprint - #6191

Open
markhannum wants to merge 2 commits into
bloomberg:mainfrom
markhannum:lock-fingerprint
Open

markhannum wants to merge 2 commits into
bloomberg:mainfrom
markhannum:lock-fingerprint

Conversation

@markhannum

@markhannum markhannum commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

locks: attribute each lock to the fingerprint that took it

Feature. This adds two columns to comdb2_locks, fingerprint and fingerprint_role, stamping each lock at allocation with the acquiring thread's fingerprint and role: R for SQL execution, W for the master applying a write schedule, A for a replicant applying from the log.

A role is armed unconditionally, so locks are attributable even with fingerprint_queries, osql_send_fingerprint or log_fingerprint off; anything that is not SQL (online-recovery, schema change) reports NULL for both. A rows carry no fingerprint by design — a replicant reads its locks out of the commit record and takes them all up front, before any log record is applied, so there is no per-statement fingerprint in scope at acquisition.

The stamp is two TLS reads and a 16-byte copy on the lock-allocation path, and is taken before the wait so a lock parked in DB_LSTAT_WAITING is attributed too. It is written once, so a lock re-acquired within a transaction keeps the statement that first took it. struct __db_lock grows by 16+1 bytes; all region sizing already derives from sizeof(struct __db_lock).

New test lock_fingerprint.test polls comdb2_locks under read and write load for roles R and W, and for A on a replicant in a clustered run, pinning each check's load and poll to the same node. It also asserts the column contract: role is one of R/W/A or NULL, a fingerprint is 32 lowercase hex characters or NULL, and no lock carries a fingerprint without a role.

@roborivers roborivers left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cbuild submission: Success ✓.
Regression testing: Success ✓.

The first 10 failing tests are:
consumer_non_atomic_default_consumer_generated **quarantined**
sc_downgrade [timeout] **quarantined**

@roborivers roborivers left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cbuild submission: Success ✓.
Regression testing: Success ✓.

The first 10 failing tests are:
sc_resume
consumer_non_atomic_default_consumer_generated **quarantined**
sc_downgrade [timeout] **quarantined**
reco-ddlk-sql [timeout] **quarantined**

@markhannum
markhannum force-pushed the lock-fingerprint branch 2 times, most recently from 38d6886 to 03f5313 Compare September 3, 2026 18:29

@roborivers roborivers left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cbuild submission: Success ✓.
Regression testing: Success ✓.

The first 10 failing tests are:
sc_truncate [db unavailable at finish]
reco-ddlk-sql **quarantined**
consumer_non_atomic_default_consumer_generated **quarantined**
sc_downgrade [timeout] **quarantined**

@roborivers roborivers left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cbuild submission: Error ⚠.
Regression testing: Success ✓.

The first 10 failing tests are:
sc_redo [failed with core dumped]
sc_truncate_multiddl_generated [db unavailable at finish] **quarantined**
comdb2sys_queueodh_generated
tsa
consumer_non_atomic_default_consumer_generated **quarantined**
sc_downgrade [timeout] **quarantined**

@roborivers roborivers left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cbuild submission: Error ⚠.
Regression testing: Success ✓.

The first 10 failing tests are:
incoherent_slow [db unavailable at finish] **quarantined**
sc_resume_logicalsc_generated **quarantined**
tsa
ssl_san
consumer_non_atomic_default_consumer_generated **quarantined**
ssl_set_cmd
ssl_prefer
ssl_dbname
sc_downgrade [timeout] **quarantined**

Stamp the acquiring thread's fingerprint and role (R read, W master write-apply,
A replication apply) onto each lock, and report them as comdb2_locks.fingerprint
and .fingerprint_role -- NULL when the lock cannot be attributed.

Signed-off-by: Mark Hannum <mhannum@bloomberg.net>
Poll comdb2_locks under load for roles R and W, and for A on a replicant in a
clustered run, pinning each check's load and poll to the same node.

Signed-off-by: Mark Hannum <mhannum@bloomberg.net>

@roborivers roborivers left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cbuild submission: Error ⚠.
Regression testing: Success ✓.

The first 10 failing tests are:
comdb2sys_queueodh_generated [db unavailable at finish]
sc_resume_logicalsc_generated **quarantined**
tsa
consumer_non_atomic_default_consumer_generated **quarantined**
sc_downgrade [timeout] **quarantined**

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