diff options
author | Tor Egge <Tor.Egge@online.no> | 2022-05-02 15:35:59 +0200 |
---|---|---|
committer | Tor Egge <Tor.Egge@online.no> | 2022-05-02 15:35:59 +0200 |
commit | a2e8017775c2f9e82a01adf1175e04157c60080f (patch) | |
tree | 401b906f446298d59810e39c20fe1c86dd15a87b /searchlib | |
parent | cb39fa7835fd0bfa8cd044f35a3c19680c9be836 (diff) |
Make search::transactionlog::DomainPart::_sz member variable atomic.
Diffstat (limited to 'searchlib')
-rw-r--r-- | searchlib/src/vespa/searchlib/transactionlog/domainpart.cpp | 4 | ||||
-rw-r--r-- | searchlib/src/vespa/searchlib/transactionlog/domainpart.h | 5 |
2 files changed, 5 insertions, 4 deletions
diff --git a/searchlib/src/vespa/searchlib/transactionlog/domainpart.cpp b/searchlib/src/vespa/searchlib/transactionlog/domainpart.cpp index eea9610c7ab..38b463d6bc2 100644 --- a/searchlib/src/vespa/searchlib/transactionlog/domainpart.cpp +++ b/searchlib/src/vespa/searchlib/transactionlog/domainpart.cpp @@ -232,7 +232,7 @@ DomainPart::buildPacketMapping(bool allowTruncate) const int64_t firstPos(currPos); Packet packet = readPacket(transLog, all, TARGET_PACKET_SIZE, allowTruncate); if (!packet.empty()) { - _sz += packet.size(); + set_size(size() + packet.size()); const SerialNum firstSerial = packet.range().from(); if (currPos == _headerLen) { _range.from(firstSerial); @@ -384,7 +384,7 @@ DomainPart::commit(const SerializedChunk & serialized) int64_t firstPos(byteSize()); assert(_range.to() < range.to()); - _sz += serialized.getNumEntries(); + set_size(size() + serialized.getNumEntries()); _range.to(range.to()); if (_range.from() == 0) { _range.from(range.from()); diff --git a/searchlib/src/vespa/searchlib/transactionlog/domainpart.h b/searchlib/src/vespa/searchlib/transactionlog/domainpart.h index ea5290c433b..fd84040228d 100644 --- a/searchlib/src/vespa/searchlib/transactionlog/domainpart.h +++ b/searchlib/src/vespa/searchlib/transactionlog/domainpart.h @@ -37,7 +37,7 @@ public: return _syncedSerial; } - size_t size() const { return _sz; } + size_t size() const noexcept { return _sz.load(std::memory_order_relaxed); } size_t byteSize() const { return _byteSize.load(std::memory_order_acquire); } @@ -51,6 +51,7 @@ private: void write(FastOS_FileInterface &file, SerialNumRange range, vespalib::ConstBufferRef buf); void writeHeader(const common::FileHeaderContext &fileHeaderContext); + void set_size(size_t sz) noexcept { _sz.store(sz, std::memory_order_relaxed); } class SkipInfo { @@ -72,7 +73,7 @@ private: std::mutex _lock; std::mutex _fileLock; SerialNumRange _range; - size_t _sz; + std::atomic<size_t> _sz; std::atomic<uint64_t> _byteSize; vespalib::string _fileName; std::unique_ptr<FastOS_FileInterface> _transLog; |