diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2018-01-12 14:10:46 +0100 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2018-01-12 14:10:46 +0100 |
commit | 1cfdc4c63e3cee2906b769bde2f74b296e621d81 (patch) | |
tree | ae675b0afe5c2853e83cc0f98343dec6f0424184 /searchlib/src | |
parent | 5eaaf4252fb2b4f1f7f69499ce17acefd0e3b949 (diff) |
Ensure that we do not drop it on the floor.
Diffstat (limited to 'searchlib/src')
3 files changed, 11 insertions, 7 deletions
diff --git a/searchlib/src/tests/transactionlog/translogclient_test.sh b/searchlib/src/tests/transactionlog/translogclient_test.sh index 46d43ddd718..039cd1a5ae1 100755 --- a/searchlib/src/tests/transactionlog/translogclient_test.sh +++ b/searchlib/src/tests/transactionlog/translogclient_test.sh @@ -3,4 +3,3 @@ set -e rm -rf test7 test8 test9 test10 test11 test12 test13 testremove $VALGRIND ./searchlib_translogclient_test_app -rm -rf test7 test8 test9 test10 test11 test12 test13 testremove diff --git a/searchlib/src/vespa/searchlib/transactionlog/domain.cpp b/searchlib/src/vespa/searchlib/transactionlog/domain.cpp index 0c699343722..813667e9d4d 100644 --- a/searchlib/src/vespa/searchlib/transactionlog/domain.cpp +++ b/searchlib/src/vespa/searchlib/transactionlog/domain.cpp @@ -320,7 +320,6 @@ waitPendingSync(vespalib::Monitor &syncMonitor, bool &pendingSync) } - Domain::Chunk::Chunk() : _data(size_t(-1)), _callBacks(), @@ -328,6 +327,7 @@ Domain::Chunk::Chunk() {} Domain::Chunk::~Chunk() = default; + void Domain::Chunk::add(const Packet &packet, Writer::DoneCallback onDone) { if (_callBacks.empty()) { @@ -347,7 +347,6 @@ Domain::Chunk::age() const { void Domain::commit(const Packet & packet, Writer::DoneCallback onDone) { - std::unique_ptr<Chunk> completed; vespalib::MonitorGuard guard(_currentChunkMonitor); if (! (_lastSerial < packet.range().from())) { throw runtime_error(make_string("Incomming serial number(%ld) must be bigger than the last one (%ld).", @@ -356,11 +355,16 @@ Domain::commit(const Packet & packet, Writer::DoneCallback onDone) { _lastSerial = packet.range().to(); } _currentChunk->add(packet, std::move(onDone)); + commitIfFull(guard); +} + +void +Domain::commitIfFull(const vespalib::MonitorGuard &guard) { if (_currentChunk->sizeBytes() > _config.getChunkSizeLimit()) { - completed = grabCurrentChunk(guard); - } - if (completed) { - commitChunk(std::move(_currentChunk), guard); + auto completed = grabCurrentChunk(guard); + if (completed) { + commitChunk(std::move(completed), guard); + } } } diff --git a/searchlib/src/vespa/searchlib/transactionlog/domain.h b/searchlib/src/vespa/searchlib/transactionlog/domain.h index 553117959c7..2690f32471b 100644 --- a/searchlib/src/vespa/searchlib/transactionlog/domain.h +++ b/searchlib/src/vespa/searchlib/transactionlog/domain.h @@ -104,6 +104,7 @@ public: private: void Run(FastOS_ThreadInterface *thisThread, void *arguments) override; void commitIfStale(const vespalib::MonitorGuard & guard); + void commitIfFull(const vespalib::MonitorGuard & guard); class Chunk { public: Chunk(); |