fix creation of keyspaces

When we call merge_keyspaces, we end up calling db.add_keyspace, which means we
don't do parts of creation of a keyspace - like creating the directory. This works
in some situations where all the work was already done, but not in others.

We should be calling create_keyspace instead, which will take care of all that
for us. That will include creating a directory when one is needed.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
This commit is contained in:
Glauber Costa
2015-06-17 14:41:33 -04:00
parent 4d07c952cc
commit 7fa8071dde

View File

@@ -576,15 +576,16 @@ std::vector<const char*> ALL { KEYSPACES, COLUMNFAMILIES, COLUMNS, TRIGGERS, USE
}
return do_with(std::move(created), [&proxy, altered = std::move(altered)] (auto& created) {
return proxy.local().get_db().invoke_on_all([&proxy, &created, altered = std::move(altered)] (database& db) {
for (auto&& kv : created) {
auto ksm = create_keyspace_from_schema_partition(kv);
keyspace k(ksm, db.make_keyspace_config(*ksm));
k.create_replication_strategy(ksm->strategy_options());
db.add_keyspace(ksm->name(), std::move(k));
}
for (auto&& name : altered) {
db.update_keyspace(name);
}
return do_for_each(created, [&db] (auto&& val) {
auto ksm = create_keyspace_from_schema_partition(val);
return db.create_keyspace(std::move(ksm));
}).then([altered = std::move(altered), &db] () mutable {
for (auto&& name : altered) {
db.update_keyspace(name);
}
return make_ready_future<>();
});
});
}).then([dropped = std::move(dropped)] () {
return make_ready_future<std::set<sstring>>(dropped);