summaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2019-02-07 18:00:13 +0100
committerGitHub <noreply@github.com>2019-02-07 18:00:13 +0100
commitaab5cfca460fc8303e6b728251797e1a2687e7c5 (patch)
tree0eba74c0283ed2d0417622b15812dd2c6c6cc80c /searchlib
parent7f315fd3d20ed977e6e8339b78b25c6a5c54b10c (diff)
parentbf8b420f07e23bb5320b66e7eb1d8f2a7cd0b7bb (diff)
Merge pull request #8418 from vespa-engine/balder/hold-the-lock-so-you-know-do-do-not-need-a-restart
Hold the lock so that restart is not needed.
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/vespa/searchlib/docstore/writeablefilechunk.cpp22
-rw-r--r--searchlib/src/vespa/searchlib/docstore/writeablefilechunk.h2
2 files changed, 9 insertions, 15 deletions
diff --git a/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.cpp b/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.cpp
index d3167060ecf..35d75300cb1 100644
--- a/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.cpp
+++ b/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.cpp
@@ -344,10 +344,9 @@ getAlignedStartPos(FastOS_File & file)
}
WriteableFileChunk::ProcessedChunkQ
-WriteableFileChunk::drainQ()
+WriteableFileChunk::drainQ(MonitorGuard & guard)
{
ProcessedChunkQ newChunks;
- MonitorGuard guard(_writeMonitor);
newChunks.swap(_writeQ);
if ( ! newChunks.empty() ) {
guard.broadcast();
@@ -496,8 +495,10 @@ WriteableFileChunk::fileWriter(const uint32_t firstChunkId)
LOG(debug, "Starting the filewriter with chunkid = %d", firstChunkId);
uint32_t nextChunkId(firstChunkId);
bool done(false);
+ MonitorGuard guard(_writeMonitor);
{
- for (ProcessedChunkQ newChunks(drainQ()); !newChunks.empty(); newChunks = drainQ()) {
+ for (ProcessedChunkQ newChunks(drainQ(guard)); !newChunks.empty(); newChunks = drainQ(guard)) {
+ guard.unlock();
insertChunks(_orderedChunks, newChunks, nextChunkId);
ProcessedChunkQ chunks(fetchNextChain(_orderedChunks, nextChunkId));
nextChunkId += chunks.size();
@@ -507,30 +508,23 @@ WriteableFileChunk::fileWriter(const uint32_t firstChunkId)
writeData(chunks, sz);
updateChunkInfo(chunks, cmetaV, sz);
LOG(spam, "bucket spread = '%3.2f'", getBucketSpread());
+ guard = MonitorGuard(_writeMonitor);
if (done) break;
}
}
LOG(debug, "Stopping the filewriter with startchunkid = %d and ending chunkid = %d done=%d",
firstChunkId, nextChunkId, done);
- MonitorGuard guard(_writeMonitor);
+ assert(_writeQ.empty());
+ _writeTaskIsRunning = false;
if (done) {
- assert(_writeQ.empty());
assert(_chunkMap.empty());
for (const ChunkInfo & cm : _chunkInfo) {
(void) cm;
assert(cm.valid() && cm.getSize() != 0);
}
- _writeTaskIsRunning = false;
guard.broadcast();
} else {
- if (_writeQ.empty()) {
- _firstChunkIdToBeWritten = nextChunkId;
- _writeTaskIsRunning = false;
- } else {
- _writeTaskIsRunning = true;
- guard.unlock();
- restart(nextChunkId);
- }
+ _firstChunkIdToBeWritten = nextChunkId;
}
}
diff --git a/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.h b/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.h
index f5923134138..bb550096251 100644
--- a/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.h
+++ b/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.h
@@ -84,7 +84,7 @@ private:
int32_t flushLastIfNonEmpty(bool force);
// _writeMonitor should not be held when calling restart
void restart(uint32_t nextChunkId);
- ProcessedChunkQ drainQ();
+ ProcessedChunkQ drainQ(vespalib::MonitorGuard & guard);
void readDataHeader();
void readIdxHeader(FastOS_FileInterface & idxFile);
void writeDataHeader(const common::FileHeaderContext &fileHeaderContext);