aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2020-09-03 11:56:10 +0200
committerGitHub <noreply@github.com>2020-09-03 11:56:10 +0200
commit56190b768988935368bf59625f042035f7ec3b89 (patch)
tree4fe1959f121ed92a07b396529c08601d4db3f0d4 /searchlib
parent9ef6075f95d8ab488af5caff1808019fd813f91b (diff)
parent41a17dfa7fe882c9508f84069484ac3b66a35ce0 (diff)
Merge pull request #14266 from vespa-engine/revert-14256-balder/remove-close
Revert "- Remove unused close() method."
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/vespa/searchlib/transactionlog/common.h1
-rw-r--r--searchlib/src/vespa/searchlib/transactionlog/domainpart.cpp55
2 files changed, 40 insertions, 16 deletions
diff --git a/searchlib/src/vespa/searchlib/transactionlog/common.h b/searchlib/src/vespa/searchlib/transactionlog/common.h
index f3276027078..db8b9727daa 100644
--- a/searchlib/src/vespa/searchlib/transactionlog/common.h
+++ b/searchlib/src/vespa/searchlib/transactionlog/common.h
@@ -72,6 +72,7 @@ public:
Packet(size_t m=0xf000) : _count(0), _range(), _limit(m), _buf(m) { }
Packet(const void * buf, size_t sz);
bool add(const Entry & data);
+ void close() { }
void clear() { _buf.clear(); _count = 0; _range.from(0); _range.to(0); }
const SerialNumRange & range() const { return _range; }
const vespalib::nbostream & getHandle() const { return _buf; }
diff --git a/searchlib/src/vespa/searchlib/transactionlog/domainpart.cpp b/searchlib/src/vespa/searchlib/transactionlog/domainpart.cpp
index afee31d609f..91599f8218a 100644
--- a/searchlib/src/vespa/searchlib/transactionlog/domainpart.cpp
+++ b/searchlib/src/vespa/searchlib/transactionlog/domainpart.cpp
@@ -27,19 +27,30 @@ namespace search::transactionlog {
namespace {
-constexpr size_t TARGET_PACKET_SIZE = 0x3f000;
+void
+handleSync(FastOS_FileInterface &file) __attribute__ ((noinline));
string
-handleWriteError(const char *text, FastOS_FileInterface &file, int64_t lastKnownGoodPos,
- SerialNumRange range, int bufLen) __attribute__ ((noinline));
+handleWriteError(const char *text,
+ FastOS_FileInterface &file,
+ int64_t lastKnownGoodPos,
+ const Packet::Entry &entry,
+ int bufLen) __attribute__ ((noinline));
bool
-handleReadError(const char *text, FastOS_FileInterface &file, ssize_t len, ssize_t rlen,
- int64_t lastKnownGoodPos, bool allowTruncate) __attribute__ ((noinline));
+handleReadError(const char *text,
+ FastOS_FileInterface &file,
+ ssize_t len,
+ ssize_t rlen,
+ int64_t lastKnownGoodPos,
+ bool allowTruncate) __attribute__ ((noinline));
-void handleSync(FastOS_FileInterface &file) __attribute__ ((noinline));
-bool addPacket(Packet &packet, const Packet::Entry &e) __attribute__ ((noinline));
-bool tailOfFileIsZero(FastOS_FileInterface &file, int64_t lastKnownGoodPos) __attribute__ ((noinline));
+bool
+addPacket(Packet &packet,
+ const Packet::Entry &e) __attribute__ ((noinline));
+
+bool
+tailOfFileIsZero(FastOS_FileInterface &file, int64_t lastKnownGoodPos) __attribute__ ((noinline));
bool
addPacket(Packet &packet, const Packet::Entry &e)
@@ -61,18 +72,21 @@ handleSync(FastOS_FileInterface &file)
}
string
-handleWriteError(const char *text, FastOS_FileInterface &file, int64_t lastKnownGoodPos,
- SerialNumRange range, int bufLen)
+handleWriteError(const char *text,
+ FastOS_FileInterface &file,
+ int64_t lastKnownGoodPos,
+ const Packet::Entry &entry,
+ int bufLen)
{
string last(FastOS_File::getLastErrorString());
- string e(make_string("%s. File '%s' at position %" PRId64 " for entries [%" PRIu64 ", %" PRIu64 "] of length %u. "
+ string e(make_string("%s. File '%s' at position %" PRId64 " for entry %" PRIu64 " of length %u. "
"OS says '%s'. Rewind to last known good position %" PRId64 ".",
- text, file.GetFileName(), file.GetPosition(), range.from(), range.to(), bufLen,
+ text, file.GetFileName(), file.GetPosition(), entry.serial(), bufLen,
last.c_str(), lastKnownGoodPos));
LOG(error, "%s", e.c_str());
if ( ! file.SetPosition(lastKnownGoodPos) ) {
last = FastOS_File::getLastErrorString();
- throw runtime_error(make_string("Failed setting position %" PRId64 " of file '%s' of size %" PRId64 " : OS says '%s'",
+ throw runtime_error(make_string("Failed setting position %" PRId64 " of file '%s' of size %" PRId64 ": OS says '%s'",
lastKnownGoodPos, file.GetFileName(), file.GetSize(), last.c_str()));
}
handleSync(file);
@@ -104,8 +118,12 @@ tailOfFileIsZero(FastOS_FileInterface &file, int64_t lastKnownGoodPos)
}
bool
-handleReadError(const char *text, FastOS_FileInterface &file, ssize_t len, ssize_t rlen,
- int64_t lastKnownGoodPos, bool allowTruncate)
+handleReadError(const char *text,
+ FastOS_FileInterface &file,
+ ssize_t len,
+ ssize_t rlen,
+ int64_t lastKnownGoodPos,
+ bool allowTruncate)
{
bool retval(true);
if (rlen != -1) {
@@ -233,6 +251,7 @@ DomainPart::buildPacketMapping(bool allowTruncate)
}
}
}
+ packet.close();
if (!packet.empty()) {
_packets[firstSerial] = packet;
_range.to(lastSerial);
@@ -500,9 +519,12 @@ DomainPart::visit(SerialNumRange &r, Packet &packet)
}
}
}
+ newPacket.close();
packet = newPacket;
retval = next != _packets.end();
}
+ } else {
+ packet.close();
}
} else {
/// File has been closed must continue from file.
@@ -546,6 +568,7 @@ DomainPart::visit(FastOS_FileInterface &file, SerialNumRange &r, Packet &packet)
}
}
}
+ newPacket.close();
packet = newPacket;
}
@@ -571,7 +594,7 @@ DomainPart::write(FastOS_FileInterface &file, const Packet::Entry &entry)
LockGuard guard(_writeLock);
if ( ! file.CheckedWrite(os.data(), osSize) ) {
- throw runtime_error(handleWriteError("Failed writing the entry.", file, lastKnownGoodPos, SerialNumRange(entry.serial(), entry.serial()), end - start));
+ throw runtime_error(handleWriteError("Failed writing the entry.", file, lastKnownGoodPos, entry, end - start));
}
_writtenSerial = entry.serial();
_byteSize.store(lastKnownGoodPos + osSize, std::memory_order_release);