From 99e10d38dcf0cf61351823532c23a033a8a1f894 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Thu, 9 May 2019 22:24:48 -0700 Subject: [PATCH] ircd::m::dbs: Add comment; branch expect. --- ircd/m_dbs.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ircd/m_dbs.cc b/ircd/m_dbs.cc index f4ba7750c..3bff17a8f 100644 --- a/ircd/m_dbs.cc +++ b/ircd/m_dbs.cc @@ -572,10 +572,14 @@ ircd::m::dbs::_index_event_refs_state(db::txn &txn, 0UL }; + // No previous state; nothing to do. if(!prev_state_idx) return; - if(prev_state_idx >= opts.event_idx) + // If the previous state's event_idx is greater than the event_idx of the + // event we're transacting this is almost surely a replay/rewrite. Bail + // out for now rather than corrupting the graph. + if(unlikely(prev_state_idx >= opts.event_idx)) return; thread_local char buf[EVENT_REFS_KEY_MAX_SIZE];