1
0
Fork 0

do not couple creation of indexes on statistics collections (#6052)

to successful initial creation of these collections
  Instead, try to create the indexes on every instance start

  That way even if the index creation failed initially, the indexes
  will be created on the next startup, and no user intervention
  is required but restarting

  The previous implementation did not create the indexes at all
  then, and left the user with a message saying "please create
  the index manually"
This commit is contained in:
Jan 2018-08-03 09:38:31 +02:00 committed by GitHub
parent dc2a6d3066
commit 679a2eddda
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 41 additions and 21 deletions

View File

@ -1005,37 +1005,57 @@ void StatisticsWorker::createCollection(std::string const& collection) const {
}
s.close();
methods::Collections::create(
Result r = methods::Collections::create(
&_vocbase,
collection,
TRI_COL_TYPE_DOCUMENT,
s.slice(),
false,
true,
[&](LogicalCollection& coll)->void {
VPackBuilder t;
[&](LogicalCollection&) {}
);
t.openObject();
t.add("collection", VPackValue(collection));
t.add("type", VPackValue("skiplist"));
t.add("unique", VPackValue(false));
t.add("sparse", VPackValue(false));
if (r.is(TRI_ERROR_SHUTTING_DOWN)) {
// this is somewhat an expected error
return;
}
// check if the collection already existed. this is acceptable too
if (r.fail() && !r.is(TRI_ERROR_ARANGO_DUPLICATE_NAME)) {
LOG_TOPIC(WARN, Logger::STATISTICS)
<< "could not create statistics collection '" << collection
<< "': error: " << r.errorMessage();
}
t.add("fields", VPackValue(VPackValueType::Array));
t.add(VPackValue("time"));
t.close();
t.close();
// check if the index on the collection must be created
r = methods::Collections::lookup(
&_vocbase,
collection,
[&](LogicalCollection& coll) {
VPackBuilder t;
VPackBuilder output;
Result idxRes =
methods::Indexes::ensureIndex(&coll, t.slice(), true, output);
t.openObject();
t.add("collection", VPackValue(collection));
t.add("type", VPackValue("skiplist"));
t.add("unique", VPackValue(false));
t.add("sparse", VPackValue(false));
if (!idxRes.ok()) {
LOG_TOPIC(WARN, Logger::STATISTICS)
<< "Can't create the skiplist index for collection " << collection
<< " please create it manually; error: "
<< idxRes.errorMessage();
}
t.add("fields", VPackValue(VPackValueType::Array));
t.add(VPackValue("time"));
t.close();
t.close();
VPackBuilder output;
Result idxRes =
methods::Indexes::ensureIndex(&coll, t.slice(), true, output);
if (!idxRes.ok()) {
LOG_TOPIC(WARN, Logger::STATISTICS)
<< "could not create the skiplist index for statistics collection '" << collection
<< "': error: "
<< idxRes.errorMessage();
}
}
);
}