diff --git a/searchlib/src/vespa/searchlib/diskindex/pagedict4file.cpp b/searchlib/src/vespa/searchlib/diskindex/pagedict4file.cpp index a5f49c2a3fe3..96649d27b82b 100644 --- a/searchlib/src/vespa/searchlib/diskindex/pagedict4file.cpp +++ b/searchlib/src/vespa/searchlib/diskindex/pagedict4file.cpp @@ -403,6 +403,7 @@ PageDict4FileSeqWrite::open(const vespalib::string &name, bool PageDict4FileSeqWrite::close() { + bool success = true; _pWriter->flush(); uint64_t usedPBits = _pe.getWriteOffset(); uint64_t usedSPBits = _spe.getWriteOffset(); @@ -415,28 +416,28 @@ PageDict4FileSeqWrite::close() _ssWriteContext.writeComprBuffer(true); _pWriteContext.dropComprBuf(); - _pfile.Sync(); - _pfile.Close(); + success &= _pfile.Sync(); + success &= _pfile.Close(); _pWriteContext.setFile(nullptr); _spWriteContext.dropComprBuf(); - _spfile.Sync(); - _spfile.Close(); + success &= _spfile.Sync(); + success &= _spfile.Close(); _spWriteContext.setFile(nullptr); _ssWriteContext.dropComprBuf(); - _ssfile.Sync(); - _ssfile.Close(); + success &= _ssfile.Sync(); + success &= _ssfile.Close(); _ssWriteContext.setFile(nullptr); // Update file headers - updatePHeader(usedPBits); - updateSPHeader(usedSPBits); - updateSSHeader(usedSSBits); + success &= updatePHeader(usedPBits); + success &= updateSPHeader(usedSPBits); + success &= updateSSHeader(usedSSBits); _pWriter.reset(); _spWriter.reset(); _ssWriter.reset(); - return true; + return success; } @@ -548,7 +549,7 @@ PageDict4FileSeqWrite::makeSSHeader(const FileHeaderContext &fileHeaderContext) } -void +bool PageDict4FileSeqWrite::updatePHeader(uint64_t fileBitSize) { vespalib::FileHeader h(FileSettings::DIRECTIO_ALIGNMENT); @@ -560,12 +561,13 @@ PageDict4FileSeqWrite::updatePHeader(uint64_t fileBitSize) h.putTag(Tag("frozen", 1)); h.putTag(Tag("fileBitSize", fileBitSize)); h.rewriteFile(f); - f.Sync(); - f.Close(); + bool success = f.Sync(); + success &= f.Close(); + return success; } -void +bool PageDict4FileSeqWrite::updateSPHeader(uint64_t fileBitSize) { vespalib::FileHeader h(FileSettings::DIRECTIO_ALIGNMENT); @@ -577,12 +579,13 @@ PageDict4FileSeqWrite::updateSPHeader(uint64_t fileBitSize) h.putTag(Tag("frozen", 1)); h.putTag(Tag("fileBitSize", fileBitSize)); h.rewriteFile(f); - f.Sync(); - f.Close(); + bool success = f.Sync(); + success &= f.Close(); + return success; } -void +bool PageDict4FileSeqWrite::updateSSHeader(uint64_t fileBitSize) { vespalib::FileHeader h(FileSettings::DIRECTIO_ALIGNMENT); @@ -597,8 +600,9 @@ PageDict4FileSeqWrite::updateSSHeader(uint64_t fileBitSize) assert(wordNum <= _sse._numWordIds); h.putTag(Tag("numWordIds", wordNum)); h.rewriteFile(f); - f.Sync(); - f.Close(); + bool success = f.Sync(); + success &= f.Close(); + return success; } diff --git a/searchlib/src/vespa/searchlib/diskindex/pagedict4file.h b/searchlib/src/vespa/searchlib/diskindex/pagedict4file.h index 0a68be7ae1bf..8d2340c0b391 100644 --- a/searchlib/src/vespa/searchlib/diskindex/pagedict4file.h +++ b/searchlib/src/vespa/searchlib/diskindex/pagedict4file.h @@ -108,9 +108,9 @@ class PageDict4FileSeqWrite : public index::DictionaryFileSeqWrite void makePHeader(const FileHeaderContext &fileHeaderContext); void makeSPHeader(const FileHeaderContext &fileHeaderContext); void makeSSHeader(const FileHeaderContext &fileHeaderContext); - void updatePHeader(uint64_t fileBitSize); - void updateSPHeader(uint64_t fileBitSize); - void updateSSHeader(uint64_t fileBitSize); + bool updatePHeader(uint64_t fileBitSize); + bool updateSPHeader(uint64_t fileBitSize); + bool updateSSHeader(uint64_t fileBitSize); public: PageDict4FileSeqWrite(); ~PageDict4FileSeqWrite(); diff --git a/searchlib/src/vespa/searchlib/diskindex/zcposting.cpp b/searchlib/src/vespa/searchlib/diskindex/zcposting.cpp index f4bee9f6344a..4441b868b159 100644 --- a/searchlib/src/vespa/searchlib/diskindex/zcposting.cpp +++ b/searchlib/src/vespa/searchlib/diskindex/zcposting.cpp @@ -258,7 +258,7 @@ Zc4PostingSeqWrite::makeHeader(const FileHeaderContext &fileHeaderContext) } -void +bool Zc4PostingSeqWrite::updateHeader() { vespalib::FileHeader h; @@ -271,8 +271,9 @@ Zc4PostingSeqWrite::updateHeader() h.putTag(Tag("fileBitSize", _fileBitSize)); h.putTag(Tag("numWords", _writer.get_num_words())); h.rewriteFile(f); - f.Sync(); - f.Close(); + bool success = f.Sync(); + success &= f.Close(); + return success; } @@ -320,11 +321,11 @@ Zc4PostingSeqWrite::close() _writer.on_close(); // flush and pad auto &writeContext = _writer.get_write_context(); writeContext.dropComprBuf(); - _file.Sync(); - _file.Close(); + bool success = _file.Sync(); + success &= _file.Close(); writeContext.setFile(nullptr); - updateHeader(); - return true; + success &= updateHeader(); + return success; } void diff --git a/searchlib/src/vespa/searchlib/diskindex/zcposting.h b/searchlib/src/vespa/searchlib/diskindex/zcposting.h index 24fccee9b8d2..dc23fe5b37e3 100644 --- a/searchlib/src/vespa/searchlib/diskindex/zcposting.h +++ b/searchlib/src/vespa/searchlib/diskindex/zcposting.h @@ -61,6 +61,11 @@ class Zc4PostingSeqWrite : public index::PostingListFileSeqWrite FastOS_File _file; uint64_t _fileBitSize; index::PostingListCountFileSeqWrite *const _countFile; + /** + * Make header using feature encode write context. + */ + void makeHeader(const search::common::FileHeaderContext &fileHeaderContext); + bool updateHeader(); public: Zc4PostingSeqWrite(index::PostingListCountFileSeqWrite *countFile); ~Zc4PostingSeqWrite(); @@ -81,12 +86,6 @@ class Zc4PostingSeqWrite : public index::PostingListFileSeqWrite void getParams(PostingListParams ¶ms) override; void setFeatureParams(const PostingListParams ¶ms) override; void getFeatureParams(PostingListParams ¶ms) override; - - /** - * Make header using feature encode write context. - */ - void makeHeader(const search::common::FileHeaderContext &fileHeaderContext); - void updateHeader(); }; class ZcPostingSeqWrite : public Zc4PostingSeqWrite