Skip to content

Fingerprint runtime stats master - #6121

Open
markhannum wants to merge 5 commits into
bloomberg:mainfrom
markhannum:fingerprint-runtime-stats-master
Open

Fingerprint runtime stats master#6121
markhannum wants to merge 5 commits into
bloomberg:mainfrom
markhannum:fingerprint-runtime-stats-master

Conversation

@markhannum

Copy link
Copy Markdown
Contributor

Fingerprint runtime stats: attribute write-apply I/O on the master

Summary

Part 2 of the fingerprint runtime-stats work (read-side landed in #6085).

The read-side attributes bufferpool page-in I/O to a SQL fingerprint on the node
that runs the SQL engine. Writes, though, are offloaded and applied on the
replication master's block-processor thread, which never armed the fingerprint
TLS and never received the fingerprint — so all write-apply page-ins fell into
the NO-FINGERPRINT bucket.

This transmits the originating statement's fingerprint to the master and
attributes the write-apply I/O it generates.

What changed

  • New append-only OSQL_FINGERPRINT osql op carrying the 16-byte fingerprint
    (rqid + uuid wire variants, mirroring OSQL_USEDB).
  • The replicant emits it from osql_send_usedb_logic_int, ahead of the usedb
    dedup, only when the statement's fingerprint changes within the session —
    correct per-statement attribution in multi-statement transactions.
  • The master arms a per-thread write-mode fingerprint slot on receiving the op
    (osql_process_packet) and clears it once the session finishes applying.
  • berkdb tracks write-apply page-ins in their own counters
    (n_write_pagein_read / _io) via a per-thread write-mode flag paired with
    the fingerprint TLS, so read vs write-apply I/O stays distinguishable.
  • comdb2_fingerprints gains total_write_pagein_read,
    total_write_pagein_read_io and a has_query_info flag, and now also
    surfaces fingerprints known only via write-apply (no gbl_fingerprint_hash
    entry) — e.g. on a master that never ran the statement's SQL engine.

Rollout

Gated by gbl_osql_send_fingerprint, default off. There is no osql protocol
handshake: an un-upgraded master fails the transaction on the unknown op. Keep
it off until the whole cluster is upgraded, then enable at runtime with
put tunable 'osql_send_fingerprint' 1 (or via lrl).

Testing

tests/fingerprints.test t12 (driven by fpwrite.sh): enables the tunable,
issues writes, then asserts on the master — by fingerprint hash — that the
write-apply counters are populated (total_write_pagein_read > 0,
total_write_pagein_read_io <= total_write_pagein_read). Structural invariants
only, since exact page counts are not deterministic. Full suite passes.

@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_truncate_multiddl_generated [db unavailable at finish] **quarantined**
cdb2jdbc
ssl_san
consumer_non_atomic_default_consumer_generated **quarantined**
ssl_set_cmd
ssl_prefer
ssl_dbname
sc_downgrade [timeout] **quarantined**
phys_rep_tiered [timeout]
phys_rep_tiered_firstfile_generated [timeout]

@markhannum
markhannum force-pushed the fingerprint-runtime-stats-master branch from dc97e20 to cd17022 Compare August 10, 2026 03:19

@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_logicalsc_generated **quarantined**
cdb2jdbc
timepart_noneres
consumer_non_atomic_default_consumer_generated **quarantined**
sc_downgrade [timeout] **quarantined**
phys_rep_tiered_firstfile_generated [timeout]
phys_rep_tiered_nosource_generated [timeout]
phys_rep_tiered [timeout]
reco-ddlk-sql [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:
truncatesc_offline_generated **quarantined**
cdb2jdbc
fingerprints
consumer_non_atomic_default_consumer_generated **quarantined**
sc_downgrade [timeout] **quarantined**
phys_rep_tiered [timeout]
phys_rep_tiered_nosource_generated [timeout]
phys_rep_tiered_firstfile_generated [timeout]
reco-ddlk-sql [timeout] **quarantined**

@markhannum
markhannum force-pushed the fingerprint-runtime-stats-master branch 2 times, most recently from 33c96b2 to 5e040f8 Compare August 10, 2026 12: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: Error ⚠.
Regression testing: Success ✓.

The first 10 failing tests are:
cdb2jdbc
ssl_san
consumer_non_atomic_default_consumer_generated **quarantined**
ssl_set_cmd
ssl_prefer
ssl_dbname
sc_downgrade [timeout] **quarantined**
phys_rep_tiered [timeout]
phys_rep_tiered_firstfile_generated [timeout]
phys_rep_tiered_nosource_generated [timeout]

@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]
cdb2jdbc
sc_parallel_logicalsc_generated
consumer_non_atomic_default_consumer_generated **quarantined**
sc_downgrade [timeout] **quarantined**
phys_rep_tiered [timeout]
phys_rep_tiered_nosource_generated [timeout]
phys_rep_tiered_firstfile_generated [timeout]
truncatesc_offline_generated [timeout] **quarantined**
reco-ddlk-sql [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:
cdb2jdbc
consumer_non_atomic_default_consumer_generated **quarantined**
fdb_push
sc_downgrade [timeout] **quarantined**
phys_rep_tiered [timeout]
phys_rep_tiered_firstfile_generated [timeout]
phys_rep_tiered_nosource_generated [timeout]

@markhannum
markhannum force-pushed the fingerprint-runtime-stats-master branch from 5e040f8 to c33ede1 Compare August 12, 2026 15:43

@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_truncate [db unavailable at finish]
cdb2jdbc
consumer_non_atomic_default_consumer_generated **quarantined**
sc_downgrade [timeout] **quarantined**

@markhannum
markhannum force-pushed the fingerprint-runtime-stats-master branch from c33ede1 to 7bf9eb8 Compare August 12, 2026 18:01

@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 **quarantined**
cdb2jdbc
ssl_san
consumer_non_atomic_default_consumer_generated **quarantined**
ssl_set_cmd
ssl_prefer
ssl_dbname
sc_downgrade [timeout] **quarantined**
reco-ddlk-sql [timeout] **quarantined**

Part 2 of the fingerprint runtime-stats effort (read side: PR bloomberg#6085). Writes are
applied on the master's block-processor thread, which never received the
fingerprint, so write-apply page-ins all landed in the NO-FINGERPRINT bucket.

Add an append-only OSQL_FINGERPRINT op: the replicant sends it when the
statement's fingerprint changes, the master arms a per-thread write-mode slot,
and berkdb counts write-apply page-ins into new comdb2_fingerprints columns.
Gated by gbl_osql_send_fingerprint, default OFF -- an older master rejects the
unknown op.

Signed-off-by: Mark Hannum <mhannum@bloomberg.net>
Skip the OSQL_FINGERPRINT send when the fingerprint is all-zeros (a statement
with no normalized SQL), which would pool unrelated write I/O under one key.
Plus comment fixes from review.

Signed-off-by: Mark Hannum <mhannum@bloomberg.net>
RECOM / SNAPISOL / SERIAL drain buffered writes at commit under a single USEDB,
interleaving statements, so the fingerprint must travel per row instead of
riding the USEDB as in SOSQL.

Record each row's fingerprint in a per-shad_tbl side hash (seq for ins/upd,
genid for del) and emit OSQL_FINGERPRINT during the drain when it changes. The
master apply path is unchanged.

Signed-off-by: Mark Hannum <mhannum@bloomberg.net>
Add t12 (fpwrite.sh): enable osql_send_fingerprint, issue writes, and assert on
the master that the statement's fingerprint carries write-apply page-ins.
Structural invariants only, since page counts are not deterministic.

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

Add t13 (fpwrite2.sh) covering read committed, snapshot isolation, and serial --
the levels that drain writes from shadow tables at commit. The rows it updates
and deletes must pre-exist: a row inserted and deleted in one transaction
cancels in the shadow table and never reaches the master.

Signed-off-by: Mark Hannum <mhannum@bloomberg.net>
@markhannum
markhannum force-pushed the fingerprint-runtime-stats-master branch from 7bf9eb8 to 2cb22c4 Compare August 13, 2026 06:12
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