Skip to content

Commit c6cdd5b

Browse files
committed
record count error
1 parent 4ffee8d commit c6cdd5b

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

src/cluster/multinode/volume.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ struct VolumedFile : public std::vector<Volume> {
7474
}
7575
VolumedFile(const std::string& file_name, uint64_t letter_count = 0) :
7676
list_file_(file_name),
77-
records_(0),
77+
records_(std::numeric_limits<OId>::max()),
7878
max_oid_(0),
7979
letter_count_(letter_count)
8080
{
@@ -93,11 +93,21 @@ struct VolumedFile : public std::vector<Volume> {
9393
}
9494
push_back(v);
9595
oid += v.record_count;
96-
records_ += v.record_count;
96+
if (v.record_count == std::numeric_limits<OId>::max()) {
97+
if (records_ != std::numeric_limits<OId>::max())
98+
throw std::runtime_error("Inconsistent record count");
99+
}
100+
else {
101+
if (records_ == std::numeric_limits<OId>::max())
102+
records_ = 0;
103+
records_ += v.record_count;
104+
}
97105
if (v.oid_end > 0)
98106
max_oid_ = std::max(max_oid_, v.oid_end - 1);
99107
}
100108
std::sort(begin(), end());
109+
if (empty())
110+
records_ = 0;
101111
}
102112
OId sparse_records() const {
103113
if (records_ == 0)

0 commit comments

Comments
 (0)