mirror of https://gitee.com/bigwinds/arangodb
issue 525.1: ensure RocksDB CreateIndex/DropIndex WAL markers are properly written during recovery (#8282)
* issue 525.1: ensure RocksDB CreateIndex/DropIndex WAL markers are properly writen during recovery * account for changes in devel * skip writing DropIndex marker in recovery
This commit is contained in:
parent
d86fb726e6
commit
7130ffa427
|
@ -176,18 +176,16 @@ void ensureLink(arangodb::DatabaseFeature& db,
|
|||
json.close();
|
||||
|
||||
bool created;
|
||||
// re-insert link
|
||||
if (!col->dropIndex(link->id()) || !col->createIndex(json.slice(), created) || !created) {
|
||||
LOG_TOPIC(ERR, arangodb::iresearch::TOPIC)
|
||||
<< "Failed to recreate the link '" << iid << "' to the collection '"
|
||||
<< cid << "' in the database '" << dbId;
|
||||
}
|
||||
}
|
||||
|
||||
void dropCollectionFromAllViews(arangodb::DatabaseFeature& db,
|
||||
TRI_voc_tick_t dbId, TRI_voc_cid_t collectionId) {
|
||||
// NOOP since either the IResearchView has been dropped as well
|
||||
// or the IResearchView will validate and remove any stale links on start
|
||||
// re-insert link
|
||||
if (!col->dropIndex(link->id()) // index drop failure
|
||||
|| !col->createIndex(json.slice(), created) // index creation failure
|
||||
|| !created) { // index not created
|
||||
LOG_TOPIC(ERR, arangodb::iresearch::TOPIC)
|
||||
<< "Failed to recreate an arangosearch link '" << iid << "' to the collection '" << cid << "' in the database '" << dbId;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -288,12 +286,6 @@ void IResearchRocksDBRecoveryHelper::LogData(const rocksdb::Slice& blob) {
|
|||
RocksDBLogType const type = RocksDBLogValue::type(blob);
|
||||
|
||||
switch (type) {
|
||||
case RocksDBLogType::CollectionDrop: {
|
||||
// find database, iterate over all extant views and drop collection
|
||||
TRI_voc_tick_t const dbId = RocksDBLogValue::databaseId(blob);
|
||||
TRI_voc_cid_t const collectionId = RocksDBLogValue::collectionId(blob);
|
||||
dropCollectionFromAllViews(*_dbFeature, dbId, collectionId);
|
||||
} break;
|
||||
case RocksDBLogType::IndexCreate: {
|
||||
TRI_voc_tick_t const dbId = RocksDBLogValue::databaseId(blob);
|
||||
TRI_voc_cid_t const collectionId = RocksDBLogValue::collectionId(blob);
|
||||
|
@ -323,4 +315,4 @@ void IResearchRocksDBRecoveryHelper::LogData(const rocksdb::Slice& blob) {
|
|||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- END-OF-FILE
|
||||
// -----------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
|
@ -486,6 +486,7 @@ bool RocksDBCollection::dropIndex(TRI_idx_iid_t iid) {
|
|||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
if (!toRemove) { // index not found
|
||||
// We tried to remove an index that does not exist
|
||||
events::DropIndex("", std::to_string(iid), TRI_ERROR_ARANGO_INDEX_NOT_FOUND);
|
||||
|
@ -498,22 +499,34 @@ bool RocksDBCollection::dropIndex(TRI_idx_iid_t iid) {
|
|||
TRI_ASSERT(cindex != nullptr);
|
||||
|
||||
Result res = cindex->drop();
|
||||
if (res.ok()) {
|
||||
events::DropIndex("", std::to_string(iid), TRI_ERROR_NO_ERROR);
|
||||
|
||||
// trigger compaction before deleting the object
|
||||
cindex->compact();
|
||||
|
||||
auto builder =
|
||||
_logicalCollection.toVelocyPackIgnore({"path", "statusString"}, true, true);
|
||||
|
||||
// log this event in the WAL and in the collection meta-data
|
||||
auto engine = static_cast<RocksDBEngine*>(EngineSelectorFeature::ENGINE);
|
||||
res = engine->writeCreateCollectionMarker(
|
||||
_logicalCollection.vocbase().id(), _logicalCollection.id(), builder.slice(),
|
||||
RocksDBLogValue::IndexDrop(_logicalCollection.vocbase().id(),
|
||||
_logicalCollection.id(), iid));
|
||||
if (!res.ok()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
events::DropIndex("", std::to_string(iid), TRI_ERROR_NO_ERROR);
|
||||
|
||||
cindex->compact(); // trigger compaction before deleting the object
|
||||
|
||||
auto* engine = static_cast<RocksDBEngine*>(EngineSelectorFeature::ENGINE);
|
||||
|
||||
if (!engine || engine->inRecovery()) {
|
||||
return true; // skip writing WAL marker if inRecovery()
|
||||
}
|
||||
|
||||
auto builder = // RocksDB path
|
||||
_logicalCollection.toVelocyPackIgnore({"path", "statusString"}, true, true);
|
||||
|
||||
// log this event in the WAL and in the collection meta-data
|
||||
res = engine->writeCreateCollectionMarker( // write marker
|
||||
_logicalCollection.vocbase().id(), // vocbase id
|
||||
_logicalCollection.id(), // collection id
|
||||
builder.slice(), // RocksDB path
|
||||
RocksDBLogValue::IndexDrop( // marker
|
||||
_logicalCollection.vocbase().id(), _logicalCollection.id(), iid // args
|
||||
)
|
||||
);
|
||||
|
||||
return res.ok();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue