mirror of
https://github.com/scylladb/scylladb.git
synced 2026-04-23 18:10:39 +00:00
commitlog: keep track of schema versions
Each segment chunk should contain column mappings for all schema versions used by the mutations it contains. In order to avoid duplication db::commitlog::segment remembers all schema versions already written in current chunk. Signed-off-by: Paweł Dziepak <pdziepak@scylladb.com>
This commit is contained in:
@@ -342,6 +342,8 @@ class db::commitlog::segment: public enable_lw_shared_from_this<segment> {
|
||||
time_point _sync_time;
|
||||
seastar::gate _gate;
|
||||
|
||||
std::unordered_set<table_schema_version> _known_schema_versions;
|
||||
|
||||
friend std::ostream& operator<<(std::ostream&, const segment&);
|
||||
friend class segment_manager;
|
||||
public:
|
||||
@@ -383,6 +385,16 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
bool is_schema_version_known(schema_ptr s) {
|
||||
return _known_schema_versions.count(s->version());
|
||||
}
|
||||
void add_schema_version(schema_ptr s) {
|
||||
_known_schema_versions.emplace(s->version());
|
||||
}
|
||||
void forget_schema_versions() {
|
||||
_known_schema_versions.clear();
|
||||
}
|
||||
|
||||
bool must_sync() {
|
||||
if (_segment_manager->cfg.mode == sync_mode::BATCH) {
|
||||
return true;
|
||||
@@ -545,6 +557,8 @@ public:
|
||||
out.write(uint32_t(_file_pos));
|
||||
out.write(crc.checksum());
|
||||
|
||||
forget_schema_versions();
|
||||
|
||||
// acquire read lock
|
||||
return _dwrite.read_lock().then([this, size, off, buf = std::move(buf), me]() mutable {
|
||||
auto written = make_lw_shared<size_t>(0);
|
||||
|
||||
Reference in New Issue
Block a user