dataiotech Labs
dbaguidedbaguideDBAdataxtoolsdataopsphere
Scripts Library/mongodb/#97
Script #97
mongodb
Monitoringread-onlyMin Version: 4.0

MongoDB Transaction Stats and Write Conflicts

Shows open and aborted transaction counts. Reveals long transaction and conflict problems.

#transactions#serverStatus#write-conflict
mongodb · javascript
const s = db.serverStatus();
({
  transactions: s.transactions,
  global_lock: s.globalLock.currentQueue,
  wt_concurrent: s.wiredTiger.concurrentTransactions
});
Operational Notes & Remediation Guidance

High write conflicts in WiredTiger indicate document contention from concurrent writes to the same document or index key.

Production Safety & Execution Standards
  • This script is designed for read-only diagnostics; it does not alter schema or modify data directly.
  • Prior to executing on production systems under high load, verify the target database version (Min. Version: 4.0).
  • Exercise caution with mutating actions (e.g., terminating sessions or dropping indexes) referenced in the notes section.