Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/WriterPipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ struct WriterPipeline {
continue;
}

event.preChecked = true; // pre-filter above already ran lookupEventById in ro txn
newEventsToProc.emplace_back(std::move(event));
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,10 @@ void writeEvents(lmdb::txn &txn, NegentropyFilterCache &neFilterCache, std::vect

PackedEventView packed(ev.packedStr);

if (lookupEventById(txn, packed.id()) || (i != 0 && ev.id() == evs[i-1].id())) {
bool isDup = (i != 0 && ev.id() == evs[i-1].id());
if (!isDup && !ev.preChecked) isDup = (bool) lookupEventById(txn, packed.id());

if (isDup) {
ev.status = EventWriteStatus::Duplicate;
continue;
}
Expand Down
4 changes: 4 additions & 0 deletions src/events.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ struct EventToWrite {
void *userData = nullptr;
EventWriteStatus status = EventWriteStatus::Pending;
uint64_t levId = 0;
// Set when the caller already probed this id via lookupEventById() from the same
// thread that will open writeEvents()'s txn_rw (e.g. WriterPipeline). Do not set
// from cross-thread paths (e.g. RelayIngester) where the probe snapshot may be stale.
bool preChecked = false;

EventToWrite() {}

Expand Down
Loading