@@ -632,7 +632,11 @@ void TTable::Merge(TIntrusiveConstPtr<TTxStatusPart> txStatus) noexcept
632632 if (const auto * prev = CommittedTransactions.Find (txId); Y_LIKELY (!prev) || *prev > rowVersion) {
633633 CommittedTransactions.Add (txId, rowVersion);
634634 if (!prev) {
635- RemovedTransactions.Remove (txId);
635+ if (RemovedTransactions.Remove (txId)) {
636+ // Transaction was in a removed set and now it's committed
637+ // This is not an error in some cases, but may be suspicious
638+ RemovedCommittedTxs++;
639+ }
636640 }
637641 }
638642 if (!TxRefs.contains (txId)) {
@@ -645,6 +649,10 @@ void TTable::Merge(TIntrusiveConstPtr<TTxStatusPart> txStatus) noexcept
645649 const ui64 txId = item.GetTxId ();
646650 if (const auto * prev = CommittedTransactions.Find (txId); Y_LIKELY (!prev)) {
647651 RemovedTransactions.Add (txId);
652+ } else {
653+ // Transaction is in a committed set but also removed
654+ // This is not an error in some cases, but may be suspicious
655+ RemovedCommittedTxs++;
648656 }
649657 if (!TxRefs.contains (txId)) {
650658 CheckTransactions.insert (txId);
@@ -944,7 +952,11 @@ void TTable::CommitTx(ui64 txId, TRowVersion rowVersion)
944952 if (RollbackState && RemovedTransactions.Contains (txId)) {
945953 RollbackOps.emplace_back (TRollbackAddRemovedTx{ txId });
946954 }
947- RemovedTransactions.Remove (txId);
955+ if (RemovedTransactions.Remove (txId)) {
956+ // Transaction was in a removed set and now it's committed
957+ // This is not an error in some cases, but may be suspicious
958+ RemovedCommittedTxs++;
959+ }
948960 }
949961 if (auto it = OpenTxs.find (txId); it != OpenTxs.end ()) {
950962 if (RollbackState) {
@@ -982,6 +994,10 @@ void TTable::RemoveTx(ui64 txId)
982994 }
983995 OpenTxs.erase (it);
984996 }
997+ } else {
998+ // Transaction is in a committed set but also removed
999+ // This is not an error in some cases, but may be suspicious
1000+ RemovedCommittedTxs++;
9851001 }
9861002}
9871003
@@ -1015,6 +1031,32 @@ size_t TTable::GetOpenTxCount() const
10151031 return OpenTxs.size ();
10161032}
10171033
1034+ size_t TTable::GetTxsWithDataCount () const
1035+ {
1036+ return TxRefs.size ();
1037+ }
1038+
1039+ size_t TTable::GetCommittedTxCount () const
1040+ {
1041+ return CommittedTransactions.Size ();
1042+ }
1043+
1044+ size_t TTable::GetRemovedTxCount () const
1045+ {
1046+ return RemovedTransactions.Size ();
1047+ }
1048+
1049+ TTableRuntimeStats TTable::RuntimeStats () const noexcept
1050+ {
1051+ return TTableRuntimeStats{
1052+ .OpenTxCount = OpenTxs.size (),
1053+ .TxsWithDataCount = TxRefs.size (),
1054+ .CommittedTxCount = CommittedTransactions.Size (),
1055+ .RemovedTxCount = RemovedTransactions.Size (),
1056+ .RemovedCommittedTxs = RemovedCommittedTxs,
1057+ };
1058+ }
1059+
10181060TMemTable& TTable::MemTable ()
10191061{
10201062 if (!Mutable) {
0 commit comments