Skip to content

Commit fee622f

Browse files
thawk105claude
andcommitted
feat: si (Snapshot Isolation) に検証用トレース口を追加
si_commit の write install 直後にトレースを emit。版ID = cstamp を (epoch=1, tid=cstamp) と写像 (初期版 cstamp=0 が genesis (1,0) に自然一致)。Silo と同じ trace.hh / -DTRACE 配線を再利用。si は SSN を持たず write-skew (G2) を admit する ので verifier の real-CC positive control になる。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 8b82d3e commit fee622f

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

cc/si/transaction.cc

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "include/scan_callback.hh"
1111
#include "include/transaction.hh"
1212
#include "include/version.hh"
13+
#include "../../include/trace.hh" // izanagi: #if TRACE-guarded correctness trace
1314

1415
extern bool chkClkSpan(const uint64_t start, const uint64_t stop,
1516
const uint64_t threshold);
@@ -521,6 +522,37 @@ void TxExecutor::si_commit() {
521522
GCElement((*itr).storage_, (*itr).key_, (*itr).rcdptr_, (*itr).ver_,
522523
this->cstamp_));
523524
}
525+
526+
#if TRACE
527+
// izanagi correctness trace (SI; observer-effect isolated, compiled out when
528+
// TRACE==0). cstamp_ is this txn's commit order AND the version id stamped
529+
// into every written version (ver_->cstamp_, set just above). The read set
530+
// holds the snapshot versions actually read; ver_->cstamp_ is the creating
531+
// txn's commit (0 = initial/genesis version, since Lsn starts at 0 and real
532+
// commits use ++Lsn >= 1). Encode the version id as (epoch=1, tid=cstamp) so
533+
// the verifier's (epoch,tid) model applies directly and an initial-version
534+
// read maps to genesis (1,0). All data is CC-native (cstamp_ already exists
535+
// for SI/GC). Emitted only on the committed path (node-validation abort goes
536+
// to FINISH_SI_COMMIT and never reaches here). read_set_/write_set_ are still
537+
// intact (cleared just below).
538+
{
539+
const std::uint64_t txid = izanagi_trace::next_txid();
540+
izanagi_trace::emit_commit(thid_, txid, 1, this->cstamp_);
541+
for (auto& re : read_set_) {
542+
const std::uint32_t vc = re.ver_->cstamp_.load(std::memory_order_acquire);
543+
izanagi_trace::emit_read(thid_, txid, izanagi_trace::key_to_hex(re.key_),
544+
1, vc);
545+
}
546+
for (auto& we : write_set_) {
547+
const char op = (we.op_ == OpType::INSERT) ? 'I'
548+
: (we.op_ == OpType::DELETE) ? 'D'
549+
: 'U';
550+
izanagi_trace::emit_write(thid_, txid, izanagi_trace::key_to_hex(we.key_),
551+
op, 1, this->cstamp_);
552+
}
553+
}
554+
#endif
555+
524556
// After pushing this commit's GCElements, expose the (possibly new)
525557
// queue front cstamp so other threads' gcRecord can advance safely.
526558
gcobject_.publishMinQueuedCstamp();

0 commit comments

Comments
 (0)