1
0
Fork 0

issue 355.7: ensure LogicalDataSource::vocbase() returns a reference

This commit is contained in:
Vasiliy 2018-04-09 15:38:24 +03:00
parent acf35a33bd
commit d1ce3a97ef
33 changed files with 296 additions and 313 deletions

View File

@ -57,8 +57,7 @@ int EnumerateCollectionBlock::initialize() {
if (_collection->isSatellite()) {
auto logicalCollection = _collection->getCollection();
auto cid = logicalCollection->planId();
TRI_ASSERT(logicalCollection->vocbase());
auto dbName = logicalCollection->vocbase()->name();
auto& dbName = logicalCollection->vocbase().name();
double maxWait = _engine->getQuery()->queryOptions().satelliteSyncWait;
bool inSync = false;
unsigned long waitInterval = 10000;

View File

@ -552,8 +552,8 @@ CloneShardDistribution(ClusterInfo* ci, LogicalCollection* col,
auto result = std::make_shared<std::unordered_map<std::string, std::vector<std::string>>>();
TRI_ASSERT(cid != 0);
std::string cidString = arangodb::basics::StringUtils::itoa(cid);
TRI_ASSERT(col->vocbase());
auto other = ci->getCollection(col->vocbase()->name(), cidString);
TRI_ASSERT(col);
auto other = ci->getCollection(col->vocbase().name(), cidString);
// The function guarantees that no nullptr is returned
TRI_ASSERT(other != nullptr);
@ -2634,11 +2634,10 @@ std::shared_ptr<LogicalCollection> ClusterMethods::persistCollectionInAgency(
std::shared_ptr<std::unordered_map<std::string, std::vector<std::string>>> shards = nullptr;
if (!distributeShardsLike.empty()) {
CollectionNameResolver resolver(col->vocbase());
CollectionNameResolver resolver(&(col->vocbase()));
TRI_voc_cid_t otherCid =
resolver.getCollectionIdCluster(distributeShardsLike);
if (otherCid != 0) {
shards = CloneShardDistribution(ci, col, otherCid);
} else {
@ -2703,8 +2702,7 @@ std::shared_ptr<LogicalCollection> ClusterMethods::persistCollectionInAgency(
col->setStatus(TRI_VOC_COL_STATUS_LOADED);
VPackBuilder velocy = col->toVelocyPackIgnore(ignoreKeys, false, false);
TRI_ASSERT(col->vocbase());
auto& dbName = col->vocbase()->name();
auto& dbName = col->vocbase().name();
std::string errorMsg;
int myerrno = ci->createCollectionCoordinator(
dbName,

View File

@ -119,7 +119,7 @@ void FollowerInfo::add(ServerID const& sid) {
// Now tell the agency, path is
// Current/Collections/<dbName>/<collectionID>/<shardID>
std::string path = "Current/Collections/";
path += _docColl->vocbase()->name();
path += _docColl->vocbase().name();
path += "/";
path += std::to_string(_docColl->planId());
path += "/";
@ -134,7 +134,7 @@ void FollowerInfo::add(ServerID const& sid) {
velocypack::Slice currentEntry =
res.slice()[0].get(std::vector<std::string>(
{AgencyCommManager::path(), "Current", "Collections",
_docColl->vocbase()->name(), std::to_string(_docColl->planId()),
_docColl->vocbase().name(), std::to_string(_docColl->planId()),
_docColl->name()}));
if (!currentEntry.isObject()) {
@ -145,7 +145,7 @@ void FollowerInfo::add(ServerID const& sid) {
}
} else {
auto newValue = newShardEntry(currentEntry, sid, true);
std::string key = "Current/Collections/" + _docColl->vocbase()->name() +
std::string key = "Current/Collections/" + _docColl->vocbase().name() +
"/" + std::to_string(_docColl->planId()) + "/" +
_docColl->name();
AgencyWriteTransaction trx;
@ -223,7 +223,7 @@ bool FollowerInfo::remove(ServerID const& sid) {
// Now tell the agency, path is
// Current/Collections/<dbName>/<collectionID>/<shardID>
std::string path = "Current/Collections/";
path += _docColl->vocbase()->name();
path += _docColl->vocbase().name();
path += "/";
path += std::to_string(_docColl->planId());
path += "/";
@ -237,7 +237,7 @@ bool FollowerInfo::remove(ServerID const& sid) {
velocypack::Slice currentEntry =
res.slice()[0].get(std::vector<std::string>(
{AgencyCommManager::path(), "Current", "Collections",
_docColl->vocbase()->name(), std::to_string(_docColl->planId()),
_docColl->vocbase().name(), std::to_string(_docColl->planId()),
_docColl->name()}));
if (!currentEntry.isObject()) {
@ -248,7 +248,7 @@ bool FollowerInfo::remove(ServerID const& sid) {
}
} else {
auto newValue = newShardEntry(currentEntry, sid, false);
std::string key = "Current/Collections/" + _docColl->vocbase()->name() +
std::string key = "Current/Collections/" + _docColl->vocbase().name() +
"/" + std::to_string(_docColl->planId()) + "/" +
_docColl->name();
AgencyWriteTransaction trx;

View File

@ -221,13 +221,12 @@ bool IResearchLink::init(arangodb::velocypack::Slice const& definition) {
if (collection() && definition.hasKey(VIEW_ID_FIELD)) {
auto identifier = definition.get(VIEW_ID_FIELD);
auto vocbase = collection()->vocbase();
if (vocbase && identifier.isNumber() && uint64_t(identifier.getInt()) == identifier.getUInt()) {
if (identifier.isNumber() && uint64_t(identifier.getInt()) == identifier.getUInt()) {
auto viewId = identifier.getUInt();
// NOTE: this will cause a deadlock if registering a link while view is being created
auto logicalView = vocbase->lookupView(viewId);
auto logicalView = collection()->vocbase().lookupView(viewId);
if (!logicalView || IResearchView::type() != logicalView->type()) {
LOG_TOPIC(WARN, iresearch::IResearchFeature::IRESEARCH) << "error looking up view '" << viewId << "': no such view";

View File

@ -129,7 +129,7 @@ void IResearchRocksDBLink::toVelocyPack(arangodb::velocypack::Builder& builder,
void IResearchRocksDBLink::writeRocksWalMarker() {
RocksDBLogValue logValue = RocksDBLogValue::IResearchLinkDrop(
Index::_collection->vocbase()->id(),
Index::_collection->vocbase().id(),
Index::_collection->id(),
view() ? view()->id() : 0, // 0 == invalid TRI_voc_cid_t according to transaction::Methods
Index::_iid);

View File

@ -381,7 +381,7 @@ arangodb::Result persistProperties(
if (!engine->inRecovery()) {
// change view throws exception on error
try {
engine->changeView(view.vocbase(), view.id(), view, true);
engine->changeView(&(view.vocbase()), view.id(), view, true);
} catch (std::exception const& e) {
return arangodb::Result(
TRI_ERROR_INTERNAL,
@ -436,7 +436,7 @@ arangodb::Result persistProperties(
// change view throws exception on error
try {
engine->changeView(view.vocbase(), view.id(), view, true);
engine->changeView(&(view.vocbase()), view.id(), view, true);
} catch (std::exception const& e) {
return arangodb::Result(
TRI_ERROR_INTERNAL,
@ -1140,7 +1140,7 @@ IResearchView::~IResearchView() {
if (deleted()) {
StorageEngine* engine = EngineSelectorFeature::ENGINE;
TRI_ASSERT(engine);
engine->destroyView(vocbase(), this);
engine->destroyView(&vocbase(), this);
}
}
@ -1206,34 +1206,32 @@ int IResearchView::drop(TRI_voc_cid_t cid) {
}
arangodb::Result IResearchView::dropImpl() {
std::unordered_set<TRI_voc_cid_t> collections;
arangodb::velocypack::Builder builder;
// drop all known links
if (vocbase()) {
arangodb::velocypack::Builder builder;
{
ReadMutex mutex(_mutex);
SCOPED_LOCK(mutex); // '_meta' and '_trackedCids' can be asynchronously updated
{
ReadMutex mutex(_mutex);
SCOPED_LOCK(mutex); // '_meta' and '_trackedCids' can be asynchronously updated
builder.openObject();
builder.openObject();
if (!appendLinkRemoval(builder, _meta)) {
return arangodb::Result(
TRI_ERROR_INTERNAL,
std::string("failed to construct link removal directive while removing IResearch view '") + std::to_string(id()) + "'"
);
}
builder.close();
}
if (!updateLinks(collections, *(vocbase()), *this, builder.slice()).ok()) {
if (!appendLinkRemoval(builder, _meta)) {
return arangodb::Result(
TRI_ERROR_INTERNAL,
std::string("failed to remove links while removing IResearch view '") + std::to_string(id()) + "'"
std::string("failed to construct link removal directive while removing IResearch view '") + std::to_string(id()) + "'"
);
}
builder.close();
}
std::unordered_set<TRI_voc_cid_t> collections;
if (!updateLinks(collections, vocbase(), *this, builder.slice()).ok()) {
return arangodb::Result(
TRI_ERROR_INTERNAL,
std::string("failed to remove links while removing IResearch view '") + std::to_string(id()) + "'"
);
}
{
@ -1255,10 +1253,7 @@ arangodb::Result IResearchView::dropImpl() {
SCOPED_LOCK(mutex);
collections.insert(_meta._collections.begin(), _meta._collections.end());
if (vocbase()) {
validateLinks(collections, *(vocbase()), *this);
}
validateLinks(collections, vocbase(), *this);
// ArangoDB global consistency check, no known dangling links
if (!collections.empty()) {
@ -1491,7 +1486,7 @@ void IResearchView::getPropertiesVPack(
_meta.json(builder);
if (!vocbase() || forPersistence) {
if (forPersistence) {
return; // nothing more to output (persistent configuration does not need links)
}
@ -1500,7 +1495,7 @@ void IResearchView::getPropertiesVPack(
// add CIDs of known collections to list
for (auto& entry: _meta._collections) {
// skip collections missing from vocbase or UserTransaction constructor will throw an exception
if (nullptr != vocbase()->lookupCollection(entry)) {
if (vocbase().lookupCollection(entry)) {
collections.emplace_back(std::to_string(entry));
}
}
@ -1516,7 +1511,7 @@ void IResearchView::getPropertiesVPack(
try {
arangodb::transaction::UserTransaction trx(
transaction::StandaloneContext::Create(vocbase()),
transaction::StandaloneContext::Create(&vocbase()),
collections, // readCollections
EMPTY, // writeCollections
EMPTY, // exclusiveCollections
@ -2091,15 +2086,6 @@ arangodb::Result IResearchView::updateProperties(
arangodb::velocypack::Slice const& slice,
bool partialUpdate
) {
auto* vocbase = this->vocbase();
if (!vocbase) {
return arangodb::Result(
TRI_ERROR_INTERNAL,
std::string("failed to find vocbase while updating links for iResearch view '") + std::to_string(id()) + "'"
);
}
std::string error;
IResearchViewMeta meta;
IResearchViewMeta::Mask mask;
@ -2156,7 +2142,7 @@ arangodb::Result IResearchView::updateProperties(
std::unordered_set<TRI_voc_cid_t> collections;
if (partialUpdate) {
return updateLinks(collections, *vocbase, *this, slice.get(LINKS_FIELD));
return updateLinks(collections, vocbase(), *this, slice.get(LINKS_FIELD));
}
arangodb::velocypack::Builder builder;
@ -2173,7 +2159,7 @@ arangodb::Result IResearchView::updateProperties(
builder.close();
return updateLinks(collections, *vocbase, *this, builder.slice());
return updateLinks(collections, vocbase(), *this, builder.slice());
}
void IResearchView::registerFlushCallback() {
@ -2267,7 +2253,7 @@ void IResearchView::verifyKnownCollections() {
}
for (auto cid : cids) {
auto collection = vocbase()->lookupCollection(cid);
auto collection = vocbase().lookupCollection(cid);
if (!collection) {
// collection no longer exists, drop it and move on

View File

@ -378,11 +378,11 @@ bool Index::Compare(VPackSlice const& lhs, VPackSlice const& rhs) {
/// @brief return a contextual string for logging
std::string Index::context() const {
TRI_ASSERT(_collection->vocbase());
TRI_ASSERT(_collection);
std::ostringstream result;
result << "index { id: " << id() << ", type: " << oldtypeName()
<< ", collection: " << _collection->vocbase()->name() << "/"
<< ", collection: " << _collection->vocbase().name() << "/"
<< _collection->name() << ", unique: " << (_unique ? "true" : "false")
<< ", fields: ";
result << "[";

View File

@ -231,7 +231,7 @@ void MMFilesCleanupThread::cleanupCollection(arangodb::LogicalCollection* collec
isDeleted = (s == TRI_VOC_COL_STATUS_DELETED);
}
if (!isDeleted && collection->vocbase()->isDropped()) {
if (!isDeleted && collection->vocbase().isDropped()) {
// the collection was not marked as deleted, but the database was
isDeleted = true;
}

View File

@ -178,15 +178,19 @@ arangodb::Result MMFilesCollection::updateProperties(VPackSlice const& slice,
arangodb::Result MMFilesCollection::persistProperties() {
Result res;
try {
VPackBuilder infoBuilder = _logicalCollection->toVelocyPackIgnore(
{"path", "statusString"}, true, true);
MMFilesCollectionMarker marker(TRI_DF_MARKER_VPACK_CHANGE_COLLECTION,
_logicalCollection->vocbase()->id(),
_logicalCollection->id(),
infoBuilder.slice());
MMFilesCollectionMarker marker(
TRI_DF_MARKER_VPACK_CHANGE_COLLECTION,
_logicalCollection->vocbase().id(),
_logicalCollection->id(),
infoBuilder.slice()
);
MMFilesWalSlotInfoCopy slotInfo =
MMFilesLogfileManager::instance()->allocateAndWrite(marker, false);
res = slotInfo.errorCode;
} catch (arangodb::basics::Exception const& ex) {
res = ex.code();
@ -575,7 +579,7 @@ bool MMFilesCollection::isVolatile() const { return _isVolatile; }
/// @brief closes an open collection
int MMFilesCollection::close() {
if (!_logicalCollection->deleted() &&
!_logicalCollection->vocbase()->isDropped()) {
!_logicalCollection->vocbase().isDropped()) {
auto primIdx = primaryIndex();
auto idxSize = primIdx->size();
@ -589,7 +593,7 @@ int MMFilesCollection::close() {
"Database")
->forceSyncProperties();
engine->changeCollection(
_logicalCollection->vocbase(),
&(_logicalCollection->vocbase()),
_logicalCollection->id(),
_logicalCollection,
doSync
@ -1598,7 +1602,7 @@ int MMFilesCollection::fillIndexes(
PerformanceLogScope logScope(
std::string("fill-indexes-document-collection { collection: ") +
_logicalCollection->vocbase()->name() + "/" + _logicalCollection->name() +
_logicalCollection->vocbase().name() + "/" + _logicalCollection->name() +
" }, indexes: " + std::to_string(n - 1));
auto poster = [](std::function<void()> fn) -> void {
@ -1713,15 +1717,15 @@ int MMFilesCollection::fillIndexes(
/// @brief opens an existing collection
int MMFilesCollection::openWorker(bool ignoreErrors) {
auto vocbase = _logicalCollection->vocbase();
auto& vocbase = _logicalCollection->vocbase();
PerformanceLogScope logScope(std::string("open-collection { collection: ") +
vocbase->name() + "/" +
vocbase.name() + "/" +
_logicalCollection->name() + " }");
try {
// check for journals and datafiles
MMFilesEngine* engine = static_cast<MMFilesEngine*>(EngineSelectorFeature::ENGINE);
int res = engine->openCollection(vocbase, _logicalCollection, ignoreErrors);
int res = engine->openCollection(&vocbase, _logicalCollection, ignoreErrors);
if (res != TRI_ERROR_NO_ERROR) {
LOG_TOPIC(DEBUG, arangodb::Logger::FIXME) << "cannot open '" << path()
@ -1746,9 +1750,9 @@ int MMFilesCollection::openWorker(bool ignoreErrors) {
void MMFilesCollection::open(bool ignoreErrors) {
VPackBuilder builder;
StorageEngine* engine = EngineSelectorFeature::ENGINE;
auto vocbase = _logicalCollection->vocbase();
auto& vocbase = _logicalCollection->vocbase();
auto cid = _logicalCollection->id();
engine->getCollectionInfo(vocbase, cid, builder, true, 0);
engine->getCollectionInfo(&vocbase, cid, builder, true, 0);
VPackSlice initialCount =
builder.slice().get(std::vector<std::string>({"parameters", "count"}));
@ -1760,7 +1764,7 @@ void MMFilesCollection::open(bool ignoreErrors) {
}
PerformanceLogScope logScope(
std::string("open-document-collection { collection: ") + vocbase->name() +
std::string("open-document-collection { collection: ") + vocbase.name() +
"/" + _logicalCollection->name() + " }");
int res = openWorker(ignoreErrors);
@ -1773,15 +1777,15 @@ void MMFilesCollection::open(bool ignoreErrors) {
}
arangodb::SingleCollectionTransaction trx(
arangodb::transaction::StandaloneContext::Create(vocbase), cid,
arangodb::transaction::StandaloneContext::Create(&vocbase), cid,
AccessMode::Type::READ);
// the underlying collections must not be locked here because the "load"
// routine can be invoked from any other place, e.g. from an AQL query
trx.addHint(transaction::Hints::Hint::LOCK_NEVER);
{
PerformanceLogScope logScope(std::string("iterate-markers { collection: ") +
vocbase->name() + "/" +
PerformanceLogScope logScope(
std::string("iterate-markers { collection: ") + vocbase.name() + "/" +
_logicalCollection->name() + " }");
// iterate over all markers of the collection
res = iterateMarkersOnLoad(&trx);
@ -1842,7 +1846,7 @@ void MMFilesCollection::open(bool ignoreErrors) {
->forceSyncProperties();
StorageEngine* engine = EngineSelectorFeature::ENGINE;
engine->changeCollection(
_logicalCollection->vocbase(),
&(_logicalCollection->vocbase()),
_logicalCollection->id(),
_logicalCollection,
doSync
@ -2239,21 +2243,22 @@ int MMFilesCollection::saveIndex(transaction::Methods* trx,
return TRI_ERROR_OUT_OF_MEMORY;
}
auto vocbase = _logicalCollection->vocbase();
auto& vocbase = _logicalCollection->vocbase();
auto collectionId = _logicalCollection->id();
VPackSlice data = builder->slice();
StorageEngine* engine = EngineSelectorFeature::ENGINE;
engine->createIndex(vocbase, collectionId, idx->id(), data);
engine->createIndex(&vocbase, collectionId, idx->id(), data);
if (!engine->inRecovery()) {
// We need to write an index marker
try {
MMFilesCollectionMarker marker(TRI_DF_MARKER_VPACK_CREATE_INDEX,
vocbase->id(), collectionId, data);
MMFilesCollectionMarker marker(
TRI_DF_MARKER_VPACK_CREATE_INDEX, vocbase.id(), collectionId, data
);
MMFilesWalSlotInfoCopy slotInfo =
MMFilesLogfileManager::instance()->allocateAndWrite(marker, false);
res = slotInfo.errorCode;
} catch (arangodb::basics::Exception const& ex) {
LOG_TOPIC(ERR, arangodb::Logger::FIXME) << "cannot save index definition: " << ex.what();
@ -2366,7 +2371,7 @@ bool MMFilesCollection::dropIndex(TRI_idx_iid_t iid) {
events::DropIndex("", std::to_string(iid), TRI_ERROR_NO_ERROR);
return true;
}
auto vocbase = _logicalCollection->vocbase();
auto& vocbase = _logicalCollection->vocbase();
if (!removeIndex(iid)) {
// We tried to remove an index that does not exist
@ -2377,7 +2382,9 @@ bool MMFilesCollection::dropIndex(TRI_idx_iid_t iid) {
auto cid = _logicalCollection->id();
MMFilesEngine* engine = static_cast<MMFilesEngine*>(EngineSelectorFeature::ENGINE);
engine->dropIndex(vocbase, cid, iid);
engine->dropIndex(&vocbase, cid, iid);
{
bool const doSync =
application_features::ApplicationServer::getFeature<DatabaseFeature>(
@ -2395,7 +2402,7 @@ bool MMFilesCollection::dropIndex(TRI_idx_iid_t iid) {
markerBuilder.openObject();
markerBuilder.add("id", VPackValue(std::to_string(iid)));
markerBuilder.close();
engine->dropIndexWalMarker(vocbase, cid, markerBuilder.slice(), true, res);
engine->dropIndexWalMarker(&vocbase, cid, markerBuilder.slice(), true, res);
if (res == TRI_ERROR_NO_ERROR) {
events::DropIndex("", std::to_string(iid), TRI_ERROR_NO_ERROR);
@ -2482,7 +2489,7 @@ int MMFilesCollection::lockRead(bool useDeadlockDetector, TRI_voc_tid_t tid, dou
if (locker.isLocked()) {
// when we are here, we've got the read lock
if (useDeadlockDetector) {
_logicalCollection->vocbase()->_deadlockDetector.addReader(
_logicalCollection->vocbase()._deadlockDetector.addReader(
tid, _logicalCollection, wasBlocked);
}
@ -2496,7 +2503,8 @@ int MMFilesCollection::lockRead(bool useDeadlockDetector, TRI_voc_tid_t tid, dou
if (!wasBlocked) {
// insert reader
wasBlocked = true;
if (_logicalCollection->vocbase()->_deadlockDetector.setReaderBlocked(
if (_logicalCollection->vocbase()._deadlockDetector.setReaderBlocked(
tid, _logicalCollection) == TRI_ERROR_DEADLOCK) {
// deadlock
LOG_TOPIC(TRACE, arangodb::Logger::FIXME)
@ -2513,10 +2521,11 @@ int MMFilesCollection::lockRead(bool useDeadlockDetector, TRI_voc_tid_t tid, dou
// periodically check for deadlocks
TRI_ASSERT(wasBlocked);
iterations = 0;
if (_logicalCollection->vocbase()->_deadlockDetector.detectDeadlock(
if (_logicalCollection->vocbase()._deadlockDetector.detectDeadlock(
tid, _logicalCollection, false) == TRI_ERROR_DEADLOCK) {
// deadlock
_logicalCollection->vocbase()->_deadlockDetector.unsetReaderBlocked(
_logicalCollection->vocbase()._deadlockDetector.unsetReaderBlocked(
tid, _logicalCollection);
LOG_TOPIC(TRACE, arangodb::Logger::FIXME)
<< "deadlock detected while trying to acquire read-lock "
@ -2528,7 +2537,7 @@ int MMFilesCollection::lockRead(bool useDeadlockDetector, TRI_voc_tid_t tid, dou
} catch (...) {
// clean up!
if (wasBlocked) {
_logicalCollection->vocbase()->_deadlockDetector.unsetReaderBlocked(
_logicalCollection->vocbase()._deadlockDetector.unsetReaderBlocked(
tid, _logicalCollection);
}
// always exit
@ -2549,7 +2558,7 @@ int MMFilesCollection::lockRead(bool useDeadlockDetector, TRI_voc_tid_t tid, dou
if (now > startTime + timeout) {
if (useDeadlockDetector) {
_logicalCollection->vocbase()->_deadlockDetector.unsetReaderBlocked(
_logicalCollection->vocbase()._deadlockDetector.unsetReaderBlocked(
tid, _logicalCollection);
}
LOG_TOPIC(TRACE, arangodb::Logger::FIXME)
@ -2597,7 +2606,7 @@ int MMFilesCollection::lockWrite(bool useDeadlockDetector, TRI_voc_tid_t tid, do
if (locker.isLocked()) {
// register writer
if (useDeadlockDetector) {
_logicalCollection->vocbase()->_deadlockDetector.addWriter(
_logicalCollection->vocbase()._deadlockDetector.addWriter(
tid, _logicalCollection, wasBlocked);
}
// keep lock and exit loop
@ -2610,7 +2619,7 @@ int MMFilesCollection::lockWrite(bool useDeadlockDetector, TRI_voc_tid_t tid, do
if (!wasBlocked) {
// insert writer
wasBlocked = true;
if (_logicalCollection->vocbase()->_deadlockDetector.setWriterBlocked(
if (_logicalCollection->vocbase()._deadlockDetector.setWriterBlocked(
tid, _logicalCollection) == TRI_ERROR_DEADLOCK) {
// deadlock
LOG_TOPIC(TRACE, arangodb::Logger::FIXME)
@ -2626,10 +2635,11 @@ int MMFilesCollection::lockWrite(bool useDeadlockDetector, TRI_voc_tid_t tid, do
// periodically check for deadlocks
TRI_ASSERT(wasBlocked);
iterations = 0;
if (_logicalCollection->vocbase()->_deadlockDetector.detectDeadlock(
if (_logicalCollection->vocbase()._deadlockDetector.detectDeadlock(
tid, _logicalCollection, true) == TRI_ERROR_DEADLOCK) {
// deadlock
_logicalCollection->vocbase()->_deadlockDetector.unsetWriterBlocked(
_logicalCollection->vocbase()._deadlockDetector.unsetWriterBlocked(
tid, _logicalCollection);
LOG_TOPIC(TRACE, arangodb::Logger::FIXME)
<< "deadlock detected while trying to acquire "
@ -2641,7 +2651,7 @@ int MMFilesCollection::lockWrite(bool useDeadlockDetector, TRI_voc_tid_t tid, do
} catch (...) {
// clean up!
if (wasBlocked) {
_logicalCollection->vocbase()->_deadlockDetector.unsetWriterBlocked(
_logicalCollection->vocbase()._deadlockDetector.unsetWriterBlocked(
tid, _logicalCollection);
}
// always exit
@ -2662,13 +2672,15 @@ int MMFilesCollection::lockWrite(bool useDeadlockDetector, TRI_voc_tid_t tid, do
if (now > startTime + timeout) {
if (useDeadlockDetector) {
_logicalCollection->vocbase()->_deadlockDetector.unsetWriterBlocked(
_logicalCollection->vocbase()._deadlockDetector.unsetWriterBlocked(
tid, _logicalCollection);
}
LOG_TOPIC(TRACE, arangodb::Logger::FIXME)
<< "timed out after " << timeout
<< " s waiting for write-lock on collection '"
<< _logicalCollection->name() << "'";
return TRI_ERROR_LOCK_TIMEOUT;
}
@ -2699,7 +2711,7 @@ int MMFilesCollection::unlockRead(bool useDeadlockDetector, TRI_voc_tid_t tid) {
if (useDeadlockDetector) {
// unregister reader
try {
_logicalCollection->vocbase()->_deadlockDetector.unsetReader(
_logicalCollection->vocbase()._deadlockDetector.unsetReader(
tid, _logicalCollection);
} catch (...) {
}
@ -2729,7 +2741,7 @@ int MMFilesCollection::unlockWrite(bool useDeadlockDetector, TRI_voc_tid_t tid)
if (useDeadlockDetector) {
// unregister writer
try {
_logicalCollection->vocbase()->_deadlockDetector.unsetWriter(
_logicalCollection->vocbase()._deadlockDetector.unsetWriter(
tid, _logicalCollection);
} catch (...) {
// must go on here to unlock the lock
@ -3187,7 +3199,7 @@ int MMFilesCollection::detectIndexes(transaction::Methods* trx) {
VPackBuilder builder;
engine->getCollectionInfo(
_logicalCollection->vocbase(),
&(_logicalCollection->vocbase()),
_logicalCollection->id(),
builder,
true,
@ -3332,10 +3344,9 @@ Result MMFilesCollection::update(
*builder.get(), options.isRestore, revisionId);
if (_isDBServer) {
TRI_ASSERT(_logicalCollection->vocbase());
// Need to check that no sharding keys have changed:
if (arangodb::shardKeysChanged(
_logicalCollection->vocbase()->name(),
_logicalCollection->vocbase().name(),
trx->resolver()->getCollectionNameCluster(
_logicalCollection->planId()
),
@ -3471,10 +3482,9 @@ Result MMFilesCollection::replace(
options.isRestore, revisionId);
if (_isDBServer) {
TRI_ASSERT(_logicalCollection->vocbase());
// Need to check that no sharding keys have changed:
if (arangodb::shardKeysChanged(
_logicalCollection->vocbase()->name(),
_logicalCollection->vocbase().name(),
trx->resolver()->getCollectionNameCluster(
_logicalCollection->planId()
),

View File

@ -65,7 +65,9 @@ void MMFilesCollectionExport::run(uint64_t maxWaitTime, size_t limit) {
MMFilesEngine* engine = static_cast<MMFilesEngine*>(EngineSelectorFeature::ENGINE);
// try to acquire the exclusive lock on the compaction
engine->preventCompaction(_collection->vocbase(), [this](TRI_vocbase_t* vocbase) {
engine->preventCompaction(
&(_collection->vocbase()),
[this](TRI_vocbase_t* vocbase) {
// create a ditch under the compaction lock
_ditch = arangodb::MMFilesCollection::toMMFilesCollection(_collection)
->ditches()
@ -93,7 +95,7 @@ void MMFilesCollectionExport::run(uint64_t maxWaitTime, size_t limit) {
}
{
auto ctx = transaction::StandaloneContext::Create(_collection->vocbase());
auto ctx = transaction::StandaloneContext::Create(&(_collection->vocbase()));
SingleCollectionTransaction trx(ctx, _name, AccessMode::Type::READ);
// already locked by guard above

View File

@ -77,7 +77,9 @@ void MMFilesCollectionKeys::create(TRI_voc_tick_t maxTick) {
_collection->id(), 30.0
);
MMFilesEngine* engine = static_cast<MMFilesEngine*>(EngineSelectorFeature::ENGINE);
engine->preventCompaction(_collection->vocbase(), [this](TRI_vocbase_t* vocbase) {
engine->preventCompaction(
&(_collection->vocbase()),
[this](TRI_vocbase_t* vocbase) {
// create a ditch under the compaction lock
_ditch = arangodb::MMFilesCollection::toMMFilesCollection(_collection)
->ditches()
@ -93,7 +95,7 @@ void MMFilesCollectionKeys::create(TRI_voc_tick_t maxTick) {
// copy all document tokens into the result under the read-lock
{
auto ctx = transaction::StandaloneContext::Create(_collection->vocbase());
auto ctx = transaction::StandaloneContext::Create(&(_collection->vocbase()));
SingleCollectionTransaction trx(
ctx, _collection->id(), AccessMode::Type::READ
);

View File

@ -753,7 +753,7 @@ int MMFilesCollectorThread::processCollectionOperations(MMFilesCollectorCache* c
}
arangodb::SingleCollectionTransaction trx(
arangodb::transaction::StandaloneContext::Create(collection->vocbase()),
arangodb::transaction::StandaloneContext::Create(&(collection->vocbase())),
collection->id(),
AccessMode::Type::WRITE
);

View File

@ -436,7 +436,7 @@ void MMFilesCompactorThread::compactDatafiles(LogicalCollection* collection,
};
arangodb::SingleCollectionTransaction trx(
arangodb::transaction::StandaloneContext::Create(collection->vocbase()),
arangodb::transaction::StandaloneContext::Create(&(collection->vocbase())),
collection->id(),
AccessMode::Type::WRITE
);

View File

@ -1619,7 +1619,8 @@ static bool UnloadCollectionCallback(LogicalCollection* collection) {
// as the cleanup thread has already popped the unload ditch from the
// ditches list,
// we need to insert a new one to really execute the unload
collection->vocbase()->unloadCollection(collection, false);
collection->vocbase().unloadCollection(collection, false);
return false;
}

View File

@ -473,7 +473,7 @@ Result MMFilesPersistentIndex::remove(transaction::Methods* trx,
/// @brief called when the index is dropped
int MMFilesPersistentIndex::drop() {
return MMFilesPersistentIndexFeature::instance()->dropIndex(
_collection->vocbase()->id(), _collection->id(), _iid
_collection->vocbase().id(), _collection->id(), _iid
);
}

View File

@ -62,7 +62,7 @@ static void JS_RotateVocbaseCol(
}
SingleCollectionTransaction trx(
transaction::V8Context::Create(collection->vocbase(), true),
transaction::V8Context::Create(&(collection->vocbase()), true),
collection->id(),
AccessMode::Type::WRITE
);

View File

@ -110,7 +110,7 @@ void MMFilesWalRecoverState::releaseResources() {
for (auto it = openedCollections.begin(); it != openedCollections.end();
++it) {
arangodb::LogicalCollection* collection = it->second;
collection->vocbase()->releaseCollection(collection);
collection->vocbase().releaseCollection(collection);
}
openedCollections.clear();
@ -162,9 +162,9 @@ TRI_vocbase_t* MMFilesWalRecoverState::releaseDatabase(
TRI_ASSERT(collection != nullptr);
if (collection->vocbase()->id() == databaseId) {
if (collection->vocbase().id() == databaseId) {
// correct database, now release the collection
TRI_ASSERT(vocbase == collection->vocbase());
TRI_ASSERT(vocbase == &(collection->vocbase()));
vocbase->releaseCollection(collection);
// get new iterator position
it2 = openedCollections.erase(it2);
@ -192,7 +192,7 @@ arangodb::LogicalCollection* MMFilesWalRecoverState::releaseCollection(
arangodb::LogicalCollection* collection = it->second;
TRI_ASSERT(collection != nullptr);
collection->vocbase()->releaseCollection(collection);
collection->vocbase().releaseCollection(collection);
openedCollections.erase(collectionId);
return collection;
@ -1608,7 +1608,7 @@ int MMFilesWalRecoverState::fillIndexes() {
// activate secondary indexes
physical->useSecondaryIndexes(true);
auto ctx = transaction::StandaloneContext::Create(collection->vocbase());
auto ctx = transaction::StandaloneContext::Create(&(collection->vocbase()));
arangodb::SingleCollectionTransaction trx(
ctx, collection->id(), AccessMode::Type::WRITE
);

View File

@ -465,7 +465,7 @@ int MMFilesDumpCollectionReplication(MMFilesReplicationDumpContext* dump,
res = DumpCollection(
dump,
collection,
collection->vocbase()->id(),
collection->vocbase().id(),
collection->id(),
dataMin,
dataMax,

View File

@ -115,7 +115,7 @@ RocksDBCollection::RocksDBCollection(LogicalCollection* collection,
}
rocksutils::globalRocksEngine()->addCollectionMapping(
_objectId, _logicalCollection->vocbase()->id(), _logicalCollection->id()
_objectId, _logicalCollection->vocbase().id(), _logicalCollection->id()
);
if (_cacheEnabled) {
@ -136,7 +136,7 @@ RocksDBCollection::RocksDBCollection(LogicalCollection* collection,
_cacheEnabled(
static_cast<RocksDBCollection const*>(physical)->_cacheEnabled) {
rocksutils::globalRocksEngine()->addCollectionMapping(
_objectId, _logicalCollection->vocbase()->id(), _logicalCollection->id()
_objectId, _logicalCollection->vocbase().id(), _logicalCollection->id()
);
if (_cacheEnabled) {
@ -531,11 +531,11 @@ std::shared_ptr<Index> RocksDBCollection::createIndex(
VPackBuilder indexInfo;
idx->toVelocyPack(indexInfo, false, true);
res = static_cast<RocksDBEngine*>(engine)->writeCreateCollectionMarker(
_logicalCollection->vocbase()->id(),
_logicalCollection->vocbase().id(),
_logicalCollection->id(),
builder.slice(),
RocksDBLogValue::IndexCreate(
_logicalCollection->vocbase()->id(),
_logicalCollection->vocbase().id(),
_logicalCollection->id(),
indexInfo.slice()
)
@ -618,11 +618,11 @@ int RocksDBCollection::restoreIndex(transaction::Methods* trx,
static_cast<RocksDBEngine*>(EngineSelectorFeature::ENGINE);
TRI_ASSERT(engine != nullptr);
int res = engine->writeCreateCollectionMarker(
_logicalCollection->vocbase()->id(),
_logicalCollection->vocbase().id(),
_logicalCollection->id(),
builder.slice(),
RocksDBLogValue::IndexCreate(
_logicalCollection->vocbase()->id(),
_logicalCollection->vocbase().id(),
_logicalCollection->id(),
indexInfo.slice()
)
@ -688,11 +688,11 @@ bool RocksDBCollection::dropIndex(TRI_idx_iid_t iid) {
// log this event in the WAL and in the collection meta-data
int res = engine->writeCreateCollectionMarker(
_logicalCollection->vocbase()->id(),
_logicalCollection->vocbase().id(),
_logicalCollection->id(),
builder.slice(),
RocksDBLogValue::IndexDrop(
_logicalCollection->vocbase()->id(), _logicalCollection->id(), iid
_logicalCollection->vocbase().id(), _logicalCollection->id(), iid
)
);
@ -1027,10 +1027,9 @@ Result RocksDBCollection::update(arangodb::transaction::Methods* trx,
options.mergeObjects, options.keepNull, *builder.get(),
options.isRestore, revisionId);
if (_isDBServer) {
TRI_ASSERT(_logicalCollection->vocbase());
// Need to check that no sharding keys have changed:
if (arangodb::shardKeysChanged(
_logicalCollection->vocbase()->name(),
_logicalCollection->vocbase().name(),
trx->resolver()->getCollectionNameCluster(
_logicalCollection->planId()
),
@ -1136,10 +1135,9 @@ Result RocksDBCollection::replace(transaction::Methods* trx,
revisionId);
if (_isDBServer) {
TRI_ASSERT(_logicalCollection->vocbase());
// Need to check that no sharding keys have changed:
if (arangodb::shardKeysChanged(
_logicalCollection->vocbase()->name(),
_logicalCollection->vocbase().name(),
trx->resolver()->getCollectionNameCluster(
_logicalCollection->planId()
),
@ -1360,12 +1358,12 @@ int RocksDBCollection::saveIndex(transaction::Methods* trx,
}
std::shared_ptr<VPackBuilder> builder = idx->toVelocyPack(false, true);
auto vocbase = _logicalCollection->vocbase();
auto& vocbase = _logicalCollection->vocbase();
auto collectionId = _logicalCollection->id();
VPackSlice data = builder->slice();
StorageEngine* engine = EngineSelectorFeature::ENGINE;
engine->createIndex(vocbase, collectionId, idx->id(), data);
engine->createIndex(&vocbase, collectionId, idx->id(), data);
return TRI_ERROR_NO_ERROR;
}
@ -1854,7 +1852,8 @@ int RocksDBCollection::unlockRead() {
// rescans the collection to update document count
uint64_t RocksDBCollection::recalculateCounts() {
// start transaction to get a collection lock
auto ctx = transaction::StandaloneContext::Create(_logicalCollection->vocbase());
auto ctx =
transaction::StandaloneContext::Create(&(_logicalCollection->vocbase()));
SingleCollectionTransaction trx(
ctx, _logicalCollection->id(), AccessMode::Type::EXCLUSIVE
);
@ -1988,7 +1987,8 @@ void RocksDBCollection::recalculateIndexEstimates(
// method or endpoint unless the implementation changes
// start transaction to get a collection lock
auto ctx = transaction::StandaloneContext::Create(_logicalCollection->vocbase());
auto ctx =
transaction::StandaloneContext::Create(&(_logicalCollection->vocbase()));
arangodb::SingleCollectionTransaction trx(
ctx, _logicalCollection->id(), AccessMode::Type::EXCLUSIVE
);

View File

@ -67,7 +67,7 @@ RocksDBIndex::RocksDBIndex(
RocksDBEngine* engine = static_cast<RocksDBEngine*>(EngineSelectorFeature::ENGINE);
engine->addIndexMapping(
_objectId, collection->vocbase()->id(), collection->id(), _iid
_objectId, collection->vocbase().id(), collection->id(), _iid
);
}
@ -92,7 +92,7 @@ RocksDBIndex::RocksDBIndex(TRI_idx_iid_t id, LogicalCollection* collection,
RocksDBEngine* engine = static_cast<RocksDBEngine*>(EngineSelectorFeature::ENGINE);
engine->addIndexMapping(
_objectId, collection->vocbase()->id(), collection->id(), _iid
_objectId, collection->vocbase().id(), collection->id(), _iid
);
}

View File

@ -290,9 +290,8 @@ std::string CollectionNameResolver::localNameLookup(TRI_voc_cid_t cid) const {
std::shared_ptr<LogicalCollection> ci;
try {
TRI_ASSERT(it->second->vocbase());
ci = ClusterInfo::instance()->getCollection(
it->second->vocbase()->name(), name
it->second->vocbase().name(), name
);
}
catch (...) {

View File

@ -77,7 +77,7 @@ static void WeakCollectionCallback(const v8::WeakCallbackInfo<
v8g->decreaseActiveExternals();
// decrease the reference-counter for the database
TRI_ASSERT(!collection->vocbase()->isDangling());
TRI_ASSERT(!collection->vocbase().isDangling());
// find the persistent handle
#if ARANGODB_ENABLE_MAINTAINER_MODE
@ -88,12 +88,12 @@ static void WeakCollectionCallback(const v8::WeakCallbackInfo<
// dispose and clear the persistent handle
v8g->JSCollections[collection].Reset();
v8g->JSCollections.erase(collection);
if (!collection->isLocal()) {
collection->vocbase()->release();
collection->vocbase().release();
delete collection;
} else {
collection->vocbase()->release();
collection->vocbase().release();
}
}
@ -125,8 +125,9 @@ v8::Handle<v8::Object> WrapCollection(v8::Isolate* isolate,
if (it == v8g->JSCollections.end()) {
// increase the reference-counter for the database
TRI_ASSERT(!nonconstCollection->vocbase()->isDangling());
nonconstCollection->vocbase()->forceUse();
TRI_ASSERT(!nonconstCollection->vocbase().isDangling());
nonconstCollection->vocbase().forceUse();
try {
auto externalCollection = v8::External::New(isolate, nonconstCollection);
@ -138,7 +139,7 @@ v8::Handle<v8::Object> WrapCollection(v8::Isolate* isolate,
v8::WeakCallbackType::kFinalizer);
v8g->increaseActiveExternals();
} catch (...) {
nonconstCollection->vocbase()->release();
nonconstCollection->vocbase().release();
throw;
}
} else {
@ -154,7 +155,7 @@ v8::Handle<v8::Object> WrapCollection(v8::Isolate* isolate,
TRI_V8UInt64String<TRI_voc_cid_t>(isolate, collection->id()),
v8::ReadOnly
);
result->Set(_DbNameKey, TRI_V8_STD_STRING(isolate, collection->vocbase()->name()));
result->Set(_DbNameKey, TRI_V8_STD_STRING(isolate, collection->vocbase().name()));
result->ForceSet(
VersionKeyHidden,
v8::Integer::NewFromUnsigned(isolate, 5),

View File

@ -310,7 +310,7 @@ static void ExistsVocbaseVPack(
TRI_V8_THROW_EXCEPTION_INTERNAL("cannot extract collection");
}
vocbase = col->vocbase();
vocbase = &(col->vocbase());
} else {
// called as db._exists()
vocbase = GetContextVocBase(isolate);
@ -403,11 +403,8 @@ static void DocumentVocbaseCol(
if (col == nullptr) {
TRI_V8_THROW_EXCEPTION_INTERNAL("cannot extract collection");
}
TRI_vocbase_t* vocbase = col->vocbase();
collectionName = col->name();
if (vocbase == nullptr) {
TRI_V8_THROW_EXCEPTION(TRI_ERROR_ARANGO_DATABASE_NOT_FOUND);
}
VPackBuilder searchBuilder;
@ -437,11 +434,11 @@ static void DocumentVocbaseCol(
}
VPackSlice search = searchBuilder.slice();
auto transactionContext = std::make_shared<transaction::V8Context>(vocbase, true);
auto transactionContext =
std::make_shared<transaction::V8Context>(&(col->vocbase()), true);
SingleCollectionTransaction trx(transactionContext, collectionName,
AccessMode::Type::READ);
if (!args[0]->IsArray()) {
trx.addHint(transaction::Hints::Hint::SINGLE_OPERATION);
}
@ -605,13 +602,8 @@ static void RemoveVocbaseCol(v8::FunctionCallbackInfo<v8::Value> const& args) {
if (col == nullptr) {
TRI_V8_THROW_EXCEPTION_INTERNAL("cannot extract collection");
}
TRI_vocbase_t* vocbase = col->vocbase();
if (vocbase == nullptr) {
TRI_V8_THROW_EXCEPTION(TRI_ERROR_ARANGO_DATABASE_NOT_FOUND);
}
std::string collectionName = col->name();
VPackBuilder searchBuilder;
auto workOnOneDocument = [&](v8::Local<v8::Value> const searchValue, bool isBabies) {
@ -642,8 +634,10 @@ static void RemoveVocbaseCol(v8::FunctionCallbackInfo<v8::Value> const& args) {
VPackSlice toRemove = searchBuilder.slice();
auto transactionContext = std::make_shared<transaction::V8Context>(vocbase, true);
auto transactionContext =
std::make_shared<transaction::V8Context>(&(col->vocbase()), true);
SingleCollectionTransaction trx(transactionContext, collectionName, AccessMode::Type::WRITE);
if (!args[0]->IsArray()) {
trx.addHint(transaction::Hints::Hint::SINGLE_OPERATION);
}
@ -818,12 +812,6 @@ static void JS_BinaryDocumentVocbaseCol(
TRI_V8_THROW_EXCEPTION_INTERNAL("cannot extract collection");
}
TRI_vocbase_t* vocbase = col->vocbase();
if (vocbase == nullptr) {
TRI_V8_THROW_EXCEPTION(TRI_ERROR_ARANGO_DATABASE_NOT_FOUND);
}
VPackBuilder searchBuilder;
v8::Local<v8::Value> const searchValue = args[0];
collectionName = col->name();
@ -843,10 +831,8 @@ static void JS_BinaryDocumentVocbaseCol(
}
VPackSlice search = searchBuilder.slice();
auto transactionContext =
std::make_shared<transaction::V8Context>(vocbase, true);
std::make_shared<transaction::V8Context>(&(col->vocbase()), true);
SingleCollectionTransaction trx(transactionContext, collectionName,
AccessMode::Type::READ);
@ -994,7 +980,7 @@ static void JS_FiguresVocbaseCol(
}
SingleCollectionTransaction trx(
transaction::V8Context::Create(collection->vocbase(), true),
transaction::V8Context::Create(&(collection->vocbase()), true),
collection->id(),
AccessMode::Type::READ
);
@ -1037,22 +1023,22 @@ static void JS_SetTheLeader(v8::FunctionCallbackInfo<v8::Value> const& args) {
TRI_V8_THROW_EXCEPTION_INTERNAL("cannot extract collection");
}
TRI_vocbase_t* vocbase = v8Collection->vocbase();
if (vocbase == nullptr) {
TRI_V8_THROW_EXCEPTION(TRI_ERROR_ARANGO_DATABASE_NOT_FOUND);
}
std::string collectionName = v8Collection->name();
auto collection = vocbase->lookupCollection(collectionName);
auto collection = v8Collection->vocbase().lookupCollection(collectionName);
if (collection == nullptr) {
TRI_V8_THROW_EXCEPTION(TRI_ERROR_ARANGO_DATA_SOURCE_NOT_FOUND);
}
std::string theLeader;
if (args.Length() >= 1 && args[0]->IsString()) {
TRI_Utf8ValueNFC l(args[0]);
theLeader = std::string(*l, l.length());
}
collection->followers()->setTheLeader(theLeader);
if (theLeader.empty()) {
collection->followers()->clear();
}
@ -1092,16 +1078,14 @@ static void JS_GetLeader(v8::FunctionCallbackInfo<v8::Value> const& args) {
TRI_V8_THROW_EXCEPTION_INTERNAL("cannot extract collection");
}
TRI_vocbase_t* vocbase = collection->vocbase();
std::string collectionName = collection->name();
if (vocbase == nullptr) {
TRI_V8_THROW_EXCEPTION(TRI_ERROR_ARANGO_DATABASE_NOT_FOUND);
}
auto realCollection =
collection->vocbase().lookupCollection(collectionName);
auto realCollection = vocbase->lookupCollection(collectionName);
if (realCollection == nullptr) {
TRI_V8_THROW_EXCEPTION(TRI_ERROR_ARANGO_DATA_SOURCE_NOT_FOUND);
}
theLeader = realCollection->followers()->getLeader();
}
@ -1189,16 +1173,13 @@ static void JS_RemoveFollower(v8::FunctionCallbackInfo<v8::Value> const& args) {
TRI_V8_THROW_EXCEPTION_INTERNAL("cannot extract collection");
}
TRI_vocbase_t* vocbase = v8Collection->vocbase();
if (vocbase == nullptr) {
TRI_V8_THROW_EXCEPTION(TRI_ERROR_ARANGO_DATABASE_NOT_FOUND);
}
std::string collectionName = v8Collection->name();
auto collection = vocbase->lookupCollection(collectionName);
auto collection = v8Collection->vocbase().lookupCollection(collectionName);
if (collection == nullptr) {
TRI_V8_THROW_EXCEPTION(TRI_ERROR_ARANGO_DATA_SOURCE_NOT_FOUND);
}
collection->followers()->remove(serverId);
}
@ -1229,19 +1210,17 @@ static void JS_GetFollowers(v8::FunctionCallbackInfo<v8::Value> const& args) {
TRI_V8_THROW_EXCEPTION_INTERNAL("cannot extract collection");
}
TRI_vocbase_t* vocbase = v8Collection->vocbase();
if (vocbase == nullptr) {
TRI_V8_THROW_EXCEPTION(TRI_ERROR_ARANGO_DATABASE_NOT_FOUND);
}
std::string collectionName = v8Collection->name();
auto collection = vocbase->lookupCollection(collectionName);
auto collection = v8Collection->vocbase().lookupCollection(collectionName);
if (collection == nullptr) {
TRI_V8_THROW_EXCEPTION(TRI_ERROR_ARANGO_DATA_SOURCE_NOT_FOUND);
}
std::unique_ptr<arangodb::FollowerInfo> const& followerInfo = collection->followers();
std::shared_ptr<std::vector<ServerID> const> followers = followerInfo->get();
uint32_t i = 0;
for (auto const& n : *followers) {
list->Set(i++, TRI_V8_STD_STRING(isolate, n));
}
@ -1369,7 +1348,6 @@ static void JS_PropertiesVocbaseCol(
if (consoleColl == nullptr) {
TRI_V8_THROW_EXCEPTION_INTERNAL("cannot extract collection");
}
TRI_vocbase_t* vocbase = consoleColl->vocbase();
bool const isModification = (args.Length() != 0);
if (isModification) {
@ -1394,8 +1372,10 @@ static void JS_PropertiesVocbaseCol(
// in the cluster the collection object might contain outdated
// properties, which will break tests. We need an extra lookup
VPackBuilder builder;
methods::Collections::lookup(vocbase, consoleColl->name(),
[&](LogicalCollection* coll) {
methods::Collections::lookup(
&(consoleColl->vocbase()),
consoleColl->name(),
[&](LogicalCollection* coll) {
VPackObjectBuilder object(&builder, true);
Result res = methods::Collections::properties(coll, builder);
if (res.fail()) {
@ -1587,15 +1567,9 @@ static void ModifyVocbaseCol(TRI_voc_document_operation_e operation,
if (col == nullptr) {
TRI_V8_THROW_EXCEPTION_INTERNAL("cannot extract collection");
}
TRI_vocbase_t* vocbase = col->vocbase();
if (vocbase == nullptr) {
TRI_V8_THROW_EXCEPTION(TRI_ERROR_ARANGO_DATABASE_NOT_FOUND);
}
std::string collectionName = col->name();
VPackBuilder updateBuilder;
auto workOnOneSearchVal = [&](v8::Local<v8::Value> const searchVal, bool isBabies) {
std::string collName;
if (!ExtractDocumentHandle(isolate, searchVal, collName,
@ -1672,7 +1646,8 @@ static void ModifyVocbaseCol(TRI_voc_document_operation_e operation,
VPackSlice const update = updateBuilder.slice();
auto transactionContext = std::make_shared<transaction::V8Context>(vocbase, true);
auto transactionContext =
std::make_shared<transaction::V8Context>(&(col->vocbase()), true);
// Now start the transaction:
SingleCollectionTransaction trx(transactionContext, collectionName,
@ -2111,8 +2086,10 @@ static void JS_RevisionVocbaseCol(
}
TRI_voc_rid_t revisionId;
Result res = methods::Collections::revisionId(collection->vocbase(),
collection, revisionId);
auto res = methods::Collections::revisionId(
&(collection->vocbase()), collection, revisionId
);
if (res.fail()) {
TRI_V8_THROW_EXCEPTION(res);
}
@ -2277,7 +2254,7 @@ static void InsertVocbaseCol(v8::Isolate* isolate,
// load collection
auto transactionContext =
std::make_shared<transaction::V8Context>(collection->vocbase(), true);
std::make_shared<transaction::V8Context>(&(collection->vocbase()), true);
SingleCollectionTransaction trx(
transactionContext, collection->id(), AccessMode::Type::WRITE
);
@ -2387,8 +2364,7 @@ static void JS_StatusVocbaseCol(
}
if (ServerState::instance()->isCoordinator()) {
TRI_ASSERT(collection->vocbase());
auto& databaseName = collection->vocbase()->name();
auto& databaseName = collection->vocbase().name();
try {
std::shared_ptr<LogicalCollection> const ci =
@ -2428,7 +2404,7 @@ static void JS_TruncateVocbaseCol(
TRI_V8_THROW_EXCEPTION_INTERNAL("cannot extract collection");
}
auto ctx = transaction::V8Context::Create(collection->vocbase(), true);
auto ctx = transaction::V8Context::Create(&(collection->vocbase()), true);
SingleCollectionTransaction trx(
ctx, collection->id(), AccessMode::Type::EXCLUSIVE
);
@ -2469,8 +2445,7 @@ static void JS_TypeVocbaseCol(v8::FunctionCallbackInfo<v8::Value> const& args) {
}
if (ServerState::instance()->isCoordinator()) {
TRI_ASSERT(collection->vocbase());
auto& databaseName = collection->vocbase()->name();
auto& databaseName = collection->vocbase().name();
try {
std::shared_ptr<LogicalCollection> const ci =
@ -2507,7 +2482,8 @@ static void JS_UnloadVocbaseCol(
TRI_V8_THROW_EXCEPTION_INTERNAL("cannot extract collection");
}
Result res = methods::Collections::unload(collection->vocbase(), collection);
auto res = methods::Collections::unload(&(collection->vocbase()), collection);
if (res.fail()) {
TRI_V8_THROW_EXCEPTION(res);
}
@ -2803,21 +2779,19 @@ static void JS_CountVocbaseCol(
details = TRI_ObjectToBoolean(args[0]);
}
TRI_vocbase_t* vocbase = col->vocbase();
if (vocbase == nullptr) {
TRI_V8_THROW_EXCEPTION(TRI_ERROR_ARANGO_DATABASE_NOT_FOUND);
}
std::string collectionName(col->name());
SingleCollectionTransaction trx(transaction::V8Context::Create(vocbase, true), collectionName, AccessMode::Type::READ);
SingleCollectionTransaction trx(
transaction::V8Context::Create(&(col->vocbase()), true),
collectionName,
AccessMode::Type::READ
);
if (CollectionLockState::_noLockHeaders != nullptr) {
if (CollectionLockState::_noLockHeaders->find(collectionName) != CollectionLockState::_noLockHeaders->end()) {
trx.addHint(transaction::Hints::Hint::LOCK_NEVER);
}
}
Result res = trx.begin();
if (!res.ok()) {
@ -2860,8 +2834,8 @@ static void JS_WarmupVocbaseCol(
TRI_V8_THROW_EXCEPTION_INTERNAL("cannot extract collection");
}
TRI_vocbase_t* vocbase = collection->vocbase();
Result res = methods::Collections::warmup(vocbase, collection);
auto res = methods::Collections::warmup(&(collection->vocbase()), collection);
if (res.fail()) {
TRI_V8_THROW_EXCEPTION(res);
}

View File

@ -61,9 +61,14 @@ aql::QueryResultV8 AqlQuery(
TRI_ASSERT(col != nullptr);
TRI_GET_GLOBALS();
arangodb::aql::Query query(true, col->vocbase(), arangodb::aql::QueryString(aql),
bindVars, nullptr, arangodb::aql::PART_MAIN);
arangodb::aql::Query query(
true,
&(col->vocbase()),
arangodb::aql::QueryString(aql),
bindVars,
nullptr,
arangodb::aql::PART_MAIN
);
auto queryResult = query.executeV8(
isolate, static_cast<arangodb::aql::QueryRegistry*>(v8g->_queryRegistry));
@ -201,7 +206,7 @@ static void JS_AllQuery(v8::FunctionCallbackInfo<v8::Value> const& args) {
std::string const collectionName(collection->name());
std::shared_ptr<transaction::V8Context> transactionContext =
transaction::V8Context::Create(collection->vocbase(), true);
transaction::V8Context::Create(&(collection->vocbase()), true);
SingleCollectionTransaction trx(
transactionContext, collection->id(), AccessMode::Type::READ
);
@ -292,7 +297,7 @@ static void JS_AnyQuery(v8::FunctionCallbackInfo<v8::Value> const& args) {
std::string const collectionName(col->name());
std::shared_ptr<transaction::V8Context> transactionContext =
transaction::V8Context::Create(col->vocbase(), true);
transaction::V8Context::Create(&(col->vocbase()), true);
SingleCollectionTransaction trx(
transactionContext, col->id(), AccessMode::Type::READ
);

View File

@ -66,7 +66,7 @@ static void WeakViewCallback(
v8g->decreaseActiveExternals();
// decrease the reference-counter for the database
TRI_ASSERT(!view->vocbase()->isDangling());
TRI_ASSERT(!view->vocbase().isDangling());
// find the persistent handle
#if ARANGODB_ENABLE_MAINTAINER_MODE
@ -78,7 +78,7 @@ static void WeakViewCallback(
v8g->JSViews[view].Reset();
v8g->JSViews.erase(view);
view->vocbase()->release();
view->vocbase().release();
delete v; // delete the shared_ptr on the heap
}
@ -100,8 +100,9 @@ v8::Handle<v8::Object> WrapView(v8::Isolate* isolate,
if (it == v8g->JSViews.end()) {
// increase the reference-counter for the database
TRI_ASSERT(!view->vocbase()->isDangling());
view->vocbase()->forceUse();
TRI_ASSERT(!view->vocbase().isDangling());
view->vocbase().forceUse();
try {
auto v = new std::shared_ptr<arangodb::LogicalView>(view);
auto externalView = v8::External::New(isolate, v);
@ -116,7 +117,7 @@ v8::Handle<v8::Object> WrapView(v8::Isolate* isolate,
v8::WeakCallbackType::kFinalizer);
v8g->increaseActiveExternals();
} catch (...) {
view->vocbase()->release();
view->vocbase().release();
throw;
}
} else {
@ -130,7 +131,7 @@ v8::Handle<v8::Object> WrapView(v8::Isolate* isolate,
result->ForceSet(_IdKey,
TRI_V8UInt64String<TRI_voc_cid_t>(isolate, view->id()),
v8::ReadOnly);
result->Set(_DbNameKey, TRI_V8_STD_STRING(isolate, view->vocbase()->name()));
result->Set(_DbNameKey, TRI_V8_STD_STRING(isolate, view->vocbase().name()));
}
return scope.Escape<v8::Object>(result);
@ -258,7 +259,7 @@ static void JS_DropViewVocbaseObj(
PREVENT_EMBEDDED_TRANSACTION();
auto res = view->vocbase()->dropView(*view).errorNumber();
auto res = view->vocbase().dropView(*view).errorNumber();
if (res != TRI_ERROR_NO_ERROR) {
TRI_V8_THROW_EXCEPTION_MESSAGE(res, "cannot drop view");
@ -479,7 +480,7 @@ static void JS_RenameViewVocbase(
PREVENT_EMBEDDED_TRANSACTION();
int res = view->vocbase()->renameView(view, name);
int res = view->vocbase().renameView(view, name);
if (res != TRI_ERROR_NO_ERROR) {
TRI_V8_THROW_EXCEPTION_MESSAGE(res, "cannot rename view");

View File

@ -1387,7 +1387,7 @@ static void MapGetVocBase(v8::Local<v8::String> const name,
value, WRP_VOCBASE_COL_TYPE);
// check if the collection is from the same database
if (collection != nullptr && collection->vocbase() == vocbase) {
if (collection != nullptr && &(collection->vocbase()) == vocbase) {
// we cannot use collection->getStatusLocked() here, because we
// have no idea who is calling us (db[...]). The problem is that
// if we are called from within a JavaScript transaction, the

View File

@ -574,12 +574,15 @@ std::unordered_map<std::string, double> LogicalCollection::clusterIndexEstimates
if (needEstimateUpdate()){
readlock.unlock();
WRITE_LOCKER(writelock, _clusterEstimatesLock);
if(needEstimateUpdate()){
selectivityEstimatesOnCoordinator(vocbase()->name(), name(), _clusterEstimates);
selectivityEstimatesOnCoordinator(vocbase().name(), name(), _clusterEstimates);
_clusterEstimateTTL = TRI_microtime();
}
return _clusterEstimates;
}
return _clusterEstimates;
}
@ -704,7 +707,7 @@ Result LogicalCollection::rename(std::string&& newName, bool doSync) {
TRI_ASSERT(engine != nullptr);
name(std::move(newName));
engine->changeCollection(vocbase(), id(), this, doSync);
engine->changeCollection(&vocbase(), id(), this, doSync);
} catch (basics::Exception const& ex) {
// Engine Rename somehow failed. Reset to old name
name(std::move(oldName));
@ -743,7 +746,7 @@ arangodb::Result LogicalCollection::drop() {
TRI_ASSERT(!ServerState::instance()->isCoordinator());
StorageEngine* engine = EngineSelectorFeature::ENGINE;
engine->destroyCollection(vocbase(), this);
engine->destroyCollection(&vocbase(), this);
deleted(true);
_physical->drop();
@ -778,7 +781,7 @@ void LogicalCollection::toVelocyPackForClusterInventory(VPackBuilder& result,
result.add(p.value);
}
if (!_distributeShardsLike.empty()) {
CollectionNameResolver resolver(vocbase());
CollectionNameResolver resolver(&vocbase());
result.add("distributeShardsLike",
VPackValue(resolver.getCollectionNameCluster(
static_cast<TRI_voc_cid_t>(basics::StringUtils::uint64(
@ -860,7 +863,7 @@ void LogicalCollection::toVelocyPack(VPackBuilder& result, bool translateCids,
if (!_distributeShardsLike.empty() &&
ServerState::instance()->isCoordinator()) {
if (translateCids) {
CollectionNameResolver resolver(vocbase());
CollectionNameResolver resolver(&vocbase());
result.add("distributeShardsLike",
VPackValue(resolver.getCollectionNameCluster(
static_cast<TRI_voc_cid_t>(basics::StringUtils::uint64(
@ -994,13 +997,13 @@ arangodb::Result LogicalCollection::updateProperties(VPackSlice const& slice,
if (!_isLocal) {
// We need to inform the cluster as well
return ClusterInfo::instance()->setCollectionPropertiesCoordinator(
vocbase()->name(), std::to_string(id()), this
vocbase().name(), std::to_string(id()), this
);
}
StorageEngine* engine = EngineSelectorFeature::ENGINE;
engine->changeCollection(vocbase(), id(), this, doSync);
engine->changeCollection(&vocbase(), id(), this, doSync);
if (DatabaseFeature::DATABASE != nullptr &&
DatabaseFeature::DATABASE->versionTracker() != nullptr) {
DatabaseFeature::DATABASE->versionTracker()->track("change collection");
@ -1013,12 +1016,12 @@ arangodb::Result LogicalCollection::updateProperties(VPackSlice const& slice,
std::shared_ptr<arangodb::velocypack::Builder> LogicalCollection::figures() const {
if (ServerState::instance()->isCoordinator()) {
auto builder = std::make_shared<VPackBuilder>();
builder->openObject();
builder->close();
TRI_ASSERT(vocbase());
int res =
figuresOnCoordinator(vocbase()->name(), std::to_string(id()), builder);
figuresOnCoordinator(vocbase().name(), std::to_string(id()), builder);
if (res != TRI_ERROR_NO_ERROR) {
THROW_ARANGO_EXCEPTION(res);
@ -1069,8 +1072,10 @@ bool LogicalCollection::dropIndex(TRI_idx_iid_t iid) {
#if USE_PLAN_CACHE
arangodb::aql::PlanCache::instance()->invalidate(_vocbase);
#endif
arangodb::aql::QueryCache::instance()->invalidate(vocbase(), name());
arangodb::aql::QueryCache::instance()->invalidate(&vocbase(), name());
bool result = _physical->dropIndex(iid);
if (result) {
if (DatabaseFeature::DATABASE != nullptr &&
DatabaseFeature::DATABASE->versionTracker() != nullptr) {
@ -1090,7 +1095,8 @@ void LogicalCollection::persistPhysicalCollection() {
// We have not yet persisted this collection!
TRI_ASSERT(getPhysical()->path().empty());
StorageEngine* engine = EngineSelectorFeature::ENGINE;
std::string path = engine->createCollection(vocbase(), id(), this);
auto path = engine->createCollection(&vocbase(), id(), this);
getPhysical()->setPath(path);
}
@ -1242,9 +1248,8 @@ VPackSlice LogicalCollection::keyOptions() const {
}
ChecksumResult LogicalCollection::checksum(bool withRevisions, bool withData) const {
auto ctx = transaction::StandaloneContext::Create(vocbase());
auto ctx = transaction::StandaloneContext::Create(&vocbase());
SingleCollectionTransaction trx(ctx, id(), AccessMode::Type::READ);
Result res = trx.begin();
if (!res.ok()) {

View File

@ -125,7 +125,7 @@ class LogicalDataSource {
uint64_t planVersion() const noexcept { return _planVersion; }
virtual Result rename(std::string&& newName, bool doSync) = 0;
Type const& type() const noexcept { return _type; }
TRI_vocbase_t* vocbase() const noexcept { return &_vocbase; } // TODO change to reference
TRI_vocbase_t& vocbase() const noexcept { return _vocbase; }
protected:
void deleted(bool deleted) noexcept { _deleted = deleted; }

View File

@ -189,7 +189,7 @@ DBServerLogicalView::~DBServerLogicalView() {
StorageEngine* engine = EngineSelectorFeature::ENGINE;
TRI_ASSERT(engine);
engine->destroyView(vocbase(), this);
engine->destroyView(&vocbase(), this);
}
}
@ -205,7 +205,7 @@ DBServerLogicalView::~DBServerLogicalView() {
// during recovery entry is being played back from the engine
if (!engine->inRecovery()) {
arangodb::velocypack::Builder builder;
auto res = engine->getViews(view.vocbase(), builder);
auto res = engine->getViews(&(view.vocbase()), builder);
TRI_ASSERT(TRI_ERROR_NO_ERROR == res);
auto slice = builder.slice();
TRI_ASSERT(slice.isArray());
@ -227,9 +227,9 @@ DBServerLogicalView::~DBServerLogicalView() {
}
#endif
engine->createView(view.vocbase(), view.id(), view);
engine->createView(&(view.vocbase()), view.id(), view);
return engine->persistView(view.vocbase(), view);
return engine->persistView(&(view.vocbase()), view);
} catch (std::exception const& e) {
return arangodb::Result(
TRI_ERROR_INTERNAL,
@ -251,7 +251,7 @@ arangodb::Result DBServerLogicalView::drop() {
if (res.ok()) {
deleted(true);
engine->dropView(vocbase(), this);
engine->dropView(&vocbase(), this);
}
return res;
@ -269,7 +269,7 @@ Result DBServerLogicalView::rename(std::string&& newName, bool doSync) {
// store new view definition to disk
if (!engine->inRecovery()) {
engine->changeView(vocbase(), id(), *this, doSync);
engine->changeView(&vocbase(), id(), *this, doSync);
}
} catch (basics::Exception const& ex) {
name(std::move(oldName));
@ -282,7 +282,7 @@ Result DBServerLogicalView::rename(std::string&& newName, bool doSync) {
}
// write WAL 'rename' marker
return engine->renameView(vocbase(), *this, oldName);
return engine->renameView(&vocbase(), *this, oldName);
}
void DBServerLogicalView::toVelocyPack(
@ -310,7 +310,7 @@ void DBServerLogicalView::toVelocyPack(
// storage engine related properties
StorageEngine* engine = EngineSelectorFeature::ENGINE;
TRI_ASSERT(engine);
engine->getViewProperties(vocbase(), this, result);
engine->getViewProperties(&vocbase(), this, result);
}
if (includeProperties) {
@ -348,7 +348,7 @@ arangodb::Result DBServerLogicalView::updateProperties(
}
try {
engine->changeView(vocbase(), id(), *this, doSync);
engine->changeView(&vocbase(), id(), *this, doSync);
} catch (arangodb::basics::Exception const& e) {
return { e.code() };
} catch (...) {

View File

@ -241,11 +241,9 @@ Result Collections::load(TRI_vocbase_t* vocbase, LogicalCollection* coll) {
TRI_ASSERT(coll != nullptr);
if (ServerState::instance()->isCoordinator()) {
TRI_ASSERT(coll->vocbase());
#ifdef USE_ENTERPRISE
return ULColCoordinatorEnterprise(
coll->vocbase()->name(),
coll->vocbase().name(),
std::to_string(coll->id()),
TRI_VOC_COL_STATUS_LOADED
);
@ -253,7 +251,7 @@ Result Collections::load(TRI_vocbase_t* vocbase, LogicalCollection* coll) {
auto ci = ClusterInfo::instance();
return ci->setCollectionStatusCoordinator(
coll->vocbase()->name(),
coll->vocbase().name(),
std::to_string(coll->id()),
TRI_VOC_COL_STATUS_LOADED
);
@ -309,8 +307,10 @@ Result Collections::properties(LogicalCollection* coll, VPackBuilder& builder) {
// These are only relevant for cluster
ignoreKeys.insert({"distributeShardsLike", "isSmart", "numberOfShards",
"replicationFactor", "shardKeys"});
auto ctx = transaction::V8Context::CreateWhenRequired(coll->vocbase(), true);
auto ctx =
transaction::V8Context::CreateWhenRequired(&(coll->vocbase()), true);
// populate the transaction object (which is used outside this if too)
trx.reset(new SingleCollectionTransaction(
ctx, coll->id(), AccessMode::Type::READ
@ -352,14 +352,15 @@ Result Collections::updateProperties(LogicalCollection* coll,
if (ServerState::instance()->isCoordinator()) {
ClusterInfo* ci = ClusterInfo::instance();
TRI_ASSERT(coll->vocbase());
TRI_ASSERT(coll);
auto info =
ci->getCollection(coll->vocbase()->name(), std::to_string(coll->id()));
ci->getCollection(coll->vocbase().name(), std::to_string(coll->id()));
return info->updateProperties(props, false);
} else {
auto ctx = transaction::V8Context::CreateWhenRequired(coll->vocbase(), false);
auto ctx =
transaction::V8Context::CreateWhenRequired(&(coll->vocbase()), false);
SingleCollectionTransaction trx(
ctx, coll->id(), AccessMode::Type::EXCLUSIVE
);
@ -434,13 +435,14 @@ Result Collections::rename(LogicalCollection* coll, std::string const& newName,
}
std::string const oldName(coll->name());
int res = coll->vocbase()->renameCollection(coll, newName, doOverride);
int res = coll->vocbase().renameCollection(coll, newName, doOverride);
if (res != TRI_ERROR_NO_ERROR) {
return Result(res, "cannot rename collection");
}
// rename collection inside _graphs as well
return RenameGraphCollections(coll->vocbase(), oldName, newName);
return RenameGraphCollections(&(coll->vocbase()), oldName, newName);
}
#ifndef USE_ENTERPRISE
@ -455,8 +457,7 @@ static Result DropVocbaseColCoordinator(arangodb::LogicalCollection* collection,
return TRI_ERROR_FORBIDDEN;
}
TRI_ASSERT(collection->vocbase());
auto& databaseName = collection->vocbase()->name();
auto& databaseName = collection->vocbase().name();
auto cid = std::to_string(collection->id());
ClusterInfo* ci = ClusterInfo::instance();
std::string errorMsg;
@ -488,8 +489,8 @@ Result Collections::drop(TRI_vocbase_t* vocbase, LogicalCollection* coll,
}
}
TRI_ASSERT(coll->vocbase());
auto& dbname = coll->vocbase()->name();
TRI_ASSERT(coll);
auto& dbname = coll->vocbase().name();
std::string const collName = coll->name();
Result res;
@ -501,7 +502,8 @@ Result Collections::drop(TRI_vocbase_t* vocbase, LogicalCollection* coll,
res = DropVocbaseColCoordinator(coll, allowDropSystem);
#endif
} else {
int r = coll->vocbase()->dropCollection(coll, allowDropSystem, timeout);
int r = coll->vocbase().dropCollection(coll, allowDropSystem, timeout);
if (r != TRI_ERROR_NO_ERROR) {
res.reset(r, "cannot drop collection");
}
@ -558,8 +560,7 @@ Result Collections::revisionId(TRI_vocbase_t* vocbase,
LogicalCollection* coll,
TRI_voc_rid_t& rid) {
TRI_ASSERT(coll != nullptr);
TRI_ASSERT(coll->vocbase());
auto& databaseName = coll->vocbase()->name();
auto& databaseName = coll->vocbase().name();
auto cid = std::to_string(coll->id());
if (ServerState::instance()->isCoordinator()) {

View File

@ -101,8 +101,8 @@ arangodb::Result Indexes::getAll(LogicalCollection const* collection,
VPackBuilder tmp;
if (ServerState::instance()->isCoordinator()) {
TRI_ASSERT(collection->vocbase());
auto& databaseName = collection->vocbase()->name();
TRI_ASSERT(collection);
auto& databaseName = collection->vocbase().name();
std::string const& cid = collection->name();
// add code for estimates here
@ -141,7 +141,7 @@ arangodb::Result Indexes::getAll(LogicalCollection const* collection,
} else {
SingleCollectionTransaction trx(
transaction::StandaloneContext::Create(collection->vocbase()),
transaction::StandaloneContext::Create(&(collection->vocbase())),
collection->id(),
AccessMode::Type::READ
);
@ -248,14 +248,15 @@ static Result EnsureIndexLocal(arangodb::LogicalCollection* collection,
VPackSlice const& definition, bool create,
VPackBuilder& output) {
TRI_ASSERT(collection != nullptr);
READ_LOCKER(readLocker, collection->vocbase()->_inventoryLock);
READ_LOCKER(readLocker, collection->vocbase()._inventoryLock);
SingleCollectionTransaction trx(
transaction::V8Context::CreateWhenRequired(collection->vocbase(), false),
collection->id(),
create ? AccessMode::Type::EXCLUSIVE : AccessMode::Type::READ);
transaction::V8Context::CreateWhenRequired(&(collection->vocbase()), false),
collection->id(),
create ? AccessMode::Type::EXCLUSIVE : AccessMode::Type::READ
);
Result res = trx.begin();
if (!res.ok()) {
return res;
}
@ -306,8 +307,7 @@ Result Indexes::ensureIndexCoordinator(
arangodb::LogicalCollection const* collection, VPackSlice const& indexDef,
bool create, VPackBuilder& resultBuilder) {
TRI_ASSERT(collection != nullptr);
TRI_ASSERT(collection->vocbase());
auto& dbName = collection->vocbase()->name();
auto& dbName = collection->vocbase().name();
auto cid = std::to_string(collection->id());
std::string errorMsg;
@ -348,8 +348,8 @@ Result Indexes::ensureIndex(LogicalCollection* collection,
return Result(res);
}
TRI_ASSERT(collection->vocbase());
auto& dbname = collection->vocbase()->name();
TRI_ASSERT(collection);
auto& dbname = collection->vocbase().name();
std::string const collname(collection->name());
VPackSlice indexDef = defBuilder.slice();
@ -547,7 +547,7 @@ arangodb::Result Indexes::drop(LogicalCollection const* collection,
TRI_idx_iid_t iid = 0;
if (ServerState::instance()->isCoordinator()) {
CollectionNameResolver resolver(collection->vocbase());
CollectionNameResolver resolver(&(collection->vocbase()));
Result res = Indexes::extractHandle(collection, &resolver, indexArg, iid);
if (!res.ok()) {
return res;
@ -556,8 +556,8 @@ arangodb::Result Indexes::drop(LogicalCollection const* collection,
#ifdef USE_ENTERPRISE
return Indexes::dropCoordinatorEE(collection, iid);
#else
TRI_ASSERT(collection->vocbase());
auto& databaseName = collection->vocbase()->name();
TRI_ASSERT(collection);
auto& databaseName = collection->vocbase().name();
auto cid = std::to_string(collection->id());
std::string errorMsg;
int r = ClusterInfo::instance()->dropIndexCoordinator(databaseName, cid,
@ -565,12 +565,12 @@ arangodb::Result Indexes::drop(LogicalCollection const* collection,
return Result(r, errorMsg);
#endif
} else {
READ_LOCKER(readLocker, collection->vocbase()->_inventoryLock);
READ_LOCKER(readLocker, collection->vocbase()._inventoryLock);
SingleCollectionTransaction trx(
transaction::V8Context::CreateWhenRequired(collection->vocbase(), false),
collection->id(),
AccessMode::Type::EXCLUSIVE
transaction::V8Context::CreateWhenRequired(&(collection->vocbase()), false),
collection->id(),
AccessMode::Type::EXCLUSIVE
);
Result res = trx.begin();

View File

@ -428,26 +428,26 @@ bool TRI_vocbase_t::DropCollectionCallback(
} // release status lock
// remove from list of collections
TRI_vocbase_t* vocbase = collection->vocbase();
auto& vocbase = collection->vocbase();
{
RECURSIVE_WRITE_LOCKER(vocbase->_dataSourceLock, vocbase->_dataSourceLockWriteOwner);
auto it = vocbase->_collections.begin();
RECURSIVE_WRITE_LOCKER(vocbase._dataSourceLock, vocbase._dataSourceLockWriteOwner);
auto it = vocbase._collections.begin();
for (auto end = vocbase->_collections.end(); it != end; ++it) {
for (auto end = vocbase._collections.end(); it != end; ++it) {
if (it->get() == collection) {
break;
}
}
if (it != vocbase->_collections.end()) {
if (it != vocbase._collections.end()) {
auto col = *it;
vocbase->_collections.erase(it);
vocbase._collections.erase(it);
// we need to clean up the pointers later so we insert it into this vector
try {
vocbase->_deadCollections.emplace_back(col);
vocbase._deadCollections.emplace_back(col);
} catch (...) {
}
}
@ -1284,9 +1284,9 @@ int TRI_vocbase_t::dropCollection(arangodb::LogicalCollection* collection,
} else {
collection->deferDropCollection(DropCollectionCallback);
// wake up the cleanup thread
engine->signalCleanup(collection->vocbase());
engine->signalCleanup(&(collection->vocbase()));
}
if (DatabaseFeature::DATABASE != nullptr &&
DatabaseFeature::DATABASE->versionTracker() != nullptr) {
DatabaseFeature::DATABASE->versionTracker()->track("drop collection");

View File

@ -393,7 +393,7 @@ SECTION("test_async_index") {
if (!resThread0) return;
arangodb::SingleCollectionTransaction trx(
arangodb::transaction::StandaloneContext::Create(collection0->vocbase()),
arangodb::transaction::StandaloneContext::Create(&(collection0->vocbase())),
collection0->id(),
arangodb::AccessMode::Type::WRITE
);
@ -431,7 +431,7 @@ SECTION("test_async_index") {
if (!resThread1) return;
arangodb::SingleCollectionTransaction trx(
arangodb::transaction::StandaloneContext::Create(collection1->vocbase()),
arangodb::transaction::StandaloneContext::Create(&(collection1->vocbase())),
collection1->id(),
arangodb::AccessMode::Type::WRITE
);