Fix ETL race condition problem (#1132)

Wait for previous publish being finished to switch to writer.
This commit is contained in:
cyan317
2024-01-24 16:55:08 +00:00
committed by GitHub
parent 28c8fa2a9a
commit ab33b26ec4
4 changed files with 29 additions and 3 deletions

View File

@@ -40,6 +40,16 @@ LedgerCache::latestLedgerSequence() const
return latestSeq_;
}
void
LedgerCache::waitUntilCacheContainsSeq(uint32_t seq)
{
if (disabled_)
return;
std::unique_lock lock(mtx_);
cv_.wait(lock, [this, seq] { return latestSeq_ >= seq; });
return;
}
void
LedgerCache::update(std::vector<LedgerObject> const& objs, uint32_t seq, bool isBackground)
{
@@ -72,6 +82,7 @@ LedgerCache::update(std::vector<LedgerObject> const& objs, uint32_t seq, bool is
deletes_.insert(obj.key);
}
}
cv_.notify_all();
}
}