mirror of https://gitee.com/bigwinds/arangodb
issue 355.7: ensure LogicalDataSource::vocbase() returns a reference
This commit is contained in:
parent
acf35a33bd
commit
d1ce3a97ef
|
@ -57,8 +57,7 @@ int EnumerateCollectionBlock::initialize() {
|
||||||
if (_collection->isSatellite()) {
|
if (_collection->isSatellite()) {
|
||||||
auto logicalCollection = _collection->getCollection();
|
auto logicalCollection = _collection->getCollection();
|
||||||
auto cid = logicalCollection->planId();
|
auto cid = logicalCollection->planId();
|
||||||
TRI_ASSERT(logicalCollection->vocbase());
|
auto& dbName = logicalCollection->vocbase().name();
|
||||||
auto dbName = logicalCollection->vocbase()->name();
|
|
||||||
double maxWait = _engine->getQuery()->queryOptions().satelliteSyncWait;
|
double maxWait = _engine->getQuery()->queryOptions().satelliteSyncWait;
|
||||||
bool inSync = false;
|
bool inSync = false;
|
||||||
unsigned long waitInterval = 10000;
|
unsigned long waitInterval = 10000;
|
||||||
|
|
|
@ -552,8 +552,8 @@ CloneShardDistribution(ClusterInfo* ci, LogicalCollection* col,
|
||||||
auto result = std::make_shared<std::unordered_map<std::string, std::vector<std::string>>>();
|
auto result = std::make_shared<std::unordered_map<std::string, std::vector<std::string>>>();
|
||||||
TRI_ASSERT(cid != 0);
|
TRI_ASSERT(cid != 0);
|
||||||
std::string cidString = arangodb::basics::StringUtils::itoa(cid);
|
std::string cidString = arangodb::basics::StringUtils::itoa(cid);
|
||||||
TRI_ASSERT(col->vocbase());
|
TRI_ASSERT(col);
|
||||||
auto other = ci->getCollection(col->vocbase()->name(), cidString);
|
auto other = ci->getCollection(col->vocbase().name(), cidString);
|
||||||
|
|
||||||
// The function guarantees that no nullptr is returned
|
// The function guarantees that no nullptr is returned
|
||||||
TRI_ASSERT(other != nullptr);
|
TRI_ASSERT(other != nullptr);
|
||||||
|
@ -2634,8 +2634,7 @@ std::shared_ptr<LogicalCollection> ClusterMethods::persistCollectionInAgency(
|
||||||
std::shared_ptr<std::unordered_map<std::string, std::vector<std::string>>> shards = nullptr;
|
std::shared_ptr<std::unordered_map<std::string, std::vector<std::string>>> shards = nullptr;
|
||||||
|
|
||||||
if (!distributeShardsLike.empty()) {
|
if (!distributeShardsLike.empty()) {
|
||||||
|
CollectionNameResolver resolver(&(col->vocbase()));
|
||||||
CollectionNameResolver resolver(col->vocbase());
|
|
||||||
TRI_voc_cid_t otherCid =
|
TRI_voc_cid_t otherCid =
|
||||||
resolver.getCollectionIdCluster(distributeShardsLike);
|
resolver.getCollectionIdCluster(distributeShardsLike);
|
||||||
|
|
||||||
|
@ -2703,8 +2702,7 @@ std::shared_ptr<LogicalCollection> ClusterMethods::persistCollectionInAgency(
|
||||||
col->setStatus(TRI_VOC_COL_STATUS_LOADED);
|
col->setStatus(TRI_VOC_COL_STATUS_LOADED);
|
||||||
VPackBuilder velocy = col->toVelocyPackIgnore(ignoreKeys, false, false);
|
VPackBuilder velocy = col->toVelocyPackIgnore(ignoreKeys, false, false);
|
||||||
|
|
||||||
TRI_ASSERT(col->vocbase());
|
auto& dbName = col->vocbase().name();
|
||||||
auto& dbName = col->vocbase()->name();
|
|
||||||
std::string errorMsg;
|
std::string errorMsg;
|
||||||
int myerrno = ci->createCollectionCoordinator(
|
int myerrno = ci->createCollectionCoordinator(
|
||||||
dbName,
|
dbName,
|
||||||
|
|
|
@ -119,7 +119,7 @@ void FollowerInfo::add(ServerID const& sid) {
|
||||||
// Now tell the agency, path is
|
// Now tell the agency, path is
|
||||||
// Current/Collections/<dbName>/<collectionID>/<shardID>
|
// Current/Collections/<dbName>/<collectionID>/<shardID>
|
||||||
std::string path = "Current/Collections/";
|
std::string path = "Current/Collections/";
|
||||||
path += _docColl->vocbase()->name();
|
path += _docColl->vocbase().name();
|
||||||
path += "/";
|
path += "/";
|
||||||
path += std::to_string(_docColl->planId());
|
path += std::to_string(_docColl->planId());
|
||||||
path += "/";
|
path += "/";
|
||||||
|
@ -134,7 +134,7 @@ void FollowerInfo::add(ServerID const& sid) {
|
||||||
velocypack::Slice currentEntry =
|
velocypack::Slice currentEntry =
|
||||||
res.slice()[0].get(std::vector<std::string>(
|
res.slice()[0].get(std::vector<std::string>(
|
||||||
{AgencyCommManager::path(), "Current", "Collections",
|
{AgencyCommManager::path(), "Current", "Collections",
|
||||||
_docColl->vocbase()->name(), std::to_string(_docColl->planId()),
|
_docColl->vocbase().name(), std::to_string(_docColl->planId()),
|
||||||
_docColl->name()}));
|
_docColl->name()}));
|
||||||
|
|
||||||
if (!currentEntry.isObject()) {
|
if (!currentEntry.isObject()) {
|
||||||
|
@ -145,7 +145,7 @@ void FollowerInfo::add(ServerID const& sid) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
auto newValue = newShardEntry(currentEntry, sid, true);
|
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()) + "/" +
|
"/" + std::to_string(_docColl->planId()) + "/" +
|
||||||
_docColl->name();
|
_docColl->name();
|
||||||
AgencyWriteTransaction trx;
|
AgencyWriteTransaction trx;
|
||||||
|
@ -223,7 +223,7 @@ bool FollowerInfo::remove(ServerID const& sid) {
|
||||||
// Now tell the agency, path is
|
// Now tell the agency, path is
|
||||||
// Current/Collections/<dbName>/<collectionID>/<shardID>
|
// Current/Collections/<dbName>/<collectionID>/<shardID>
|
||||||
std::string path = "Current/Collections/";
|
std::string path = "Current/Collections/";
|
||||||
path += _docColl->vocbase()->name();
|
path += _docColl->vocbase().name();
|
||||||
path += "/";
|
path += "/";
|
||||||
path += std::to_string(_docColl->planId());
|
path += std::to_string(_docColl->planId());
|
||||||
path += "/";
|
path += "/";
|
||||||
|
@ -237,7 +237,7 @@ bool FollowerInfo::remove(ServerID const& sid) {
|
||||||
velocypack::Slice currentEntry =
|
velocypack::Slice currentEntry =
|
||||||
res.slice()[0].get(std::vector<std::string>(
|
res.slice()[0].get(std::vector<std::string>(
|
||||||
{AgencyCommManager::path(), "Current", "Collections",
|
{AgencyCommManager::path(), "Current", "Collections",
|
||||||
_docColl->vocbase()->name(), std::to_string(_docColl->planId()),
|
_docColl->vocbase().name(), std::to_string(_docColl->planId()),
|
||||||
_docColl->name()}));
|
_docColl->name()}));
|
||||||
|
|
||||||
if (!currentEntry.isObject()) {
|
if (!currentEntry.isObject()) {
|
||||||
|
@ -248,7 +248,7 @@ bool FollowerInfo::remove(ServerID const& sid) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
auto newValue = newShardEntry(currentEntry, sid, false);
|
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()) + "/" +
|
"/" + std::to_string(_docColl->planId()) + "/" +
|
||||||
_docColl->name();
|
_docColl->name();
|
||||||
AgencyWriteTransaction trx;
|
AgencyWriteTransaction trx;
|
||||||
|
|
|
@ -221,13 +221,12 @@ bool IResearchLink::init(arangodb::velocypack::Slice const& definition) {
|
||||||
|
|
||||||
if (collection() && definition.hasKey(VIEW_ID_FIELD)) {
|
if (collection() && definition.hasKey(VIEW_ID_FIELD)) {
|
||||||
auto identifier = definition.get(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();
|
auto viewId = identifier.getUInt();
|
||||||
|
|
||||||
// NOTE: this will cause a deadlock if registering a link while view is being created
|
// 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()) {
|
if (!logicalView || IResearchView::type() != logicalView->type()) {
|
||||||
LOG_TOPIC(WARN, iresearch::IResearchFeature::IRESEARCH) << "error looking up view '" << viewId << "': no such view";
|
LOG_TOPIC(WARN, iresearch::IResearchFeature::IRESEARCH) << "error looking up view '" << viewId << "': no such view";
|
||||||
|
|
|
@ -129,7 +129,7 @@ void IResearchRocksDBLink::toVelocyPack(arangodb::velocypack::Builder& builder,
|
||||||
|
|
||||||
void IResearchRocksDBLink::writeRocksWalMarker() {
|
void IResearchRocksDBLink::writeRocksWalMarker() {
|
||||||
RocksDBLogValue logValue = RocksDBLogValue::IResearchLinkDrop(
|
RocksDBLogValue logValue = RocksDBLogValue::IResearchLinkDrop(
|
||||||
Index::_collection->vocbase()->id(),
|
Index::_collection->vocbase().id(),
|
||||||
Index::_collection->id(),
|
Index::_collection->id(),
|
||||||
view() ? view()->id() : 0, // 0 == invalid TRI_voc_cid_t according to transaction::Methods
|
view() ? view()->id() : 0, // 0 == invalid TRI_voc_cid_t according to transaction::Methods
|
||||||
Index::_iid);
|
Index::_iid);
|
||||||
|
|
|
@ -381,7 +381,7 @@ arangodb::Result persistProperties(
|
||||||
if (!engine->inRecovery()) {
|
if (!engine->inRecovery()) {
|
||||||
// change view throws exception on error
|
// change view throws exception on error
|
||||||
try {
|
try {
|
||||||
engine->changeView(view.vocbase(), view.id(), view, true);
|
engine->changeView(&(view.vocbase()), view.id(), view, true);
|
||||||
} catch (std::exception const& e) {
|
} catch (std::exception const& e) {
|
||||||
return arangodb::Result(
|
return arangodb::Result(
|
||||||
TRI_ERROR_INTERNAL,
|
TRI_ERROR_INTERNAL,
|
||||||
|
@ -436,7 +436,7 @@ arangodb::Result persistProperties(
|
||||||
|
|
||||||
// change view throws exception on error
|
// change view throws exception on error
|
||||||
try {
|
try {
|
||||||
engine->changeView(view.vocbase(), view.id(), view, true);
|
engine->changeView(&(view.vocbase()), view.id(), view, true);
|
||||||
} catch (std::exception const& e) {
|
} catch (std::exception const& e) {
|
||||||
return arangodb::Result(
|
return arangodb::Result(
|
||||||
TRI_ERROR_INTERNAL,
|
TRI_ERROR_INTERNAL,
|
||||||
|
@ -1140,7 +1140,7 @@ IResearchView::~IResearchView() {
|
||||||
if (deleted()) {
|
if (deleted()) {
|
||||||
StorageEngine* engine = EngineSelectorFeature::ENGINE;
|
StorageEngine* engine = EngineSelectorFeature::ENGINE;
|
||||||
TRI_ASSERT(engine);
|
TRI_ASSERT(engine);
|
||||||
engine->destroyView(vocbase(), this);
|
engine->destroyView(&vocbase(), this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1206,12 +1206,9 @@ int IResearchView::drop(TRI_voc_cid_t cid) {
|
||||||
}
|
}
|
||||||
|
|
||||||
arangodb::Result IResearchView::dropImpl() {
|
arangodb::Result IResearchView::dropImpl() {
|
||||||
std::unordered_set<TRI_voc_cid_t> collections;
|
|
||||||
|
|
||||||
// drop all known links
|
|
||||||
if (vocbase()) {
|
|
||||||
arangodb::velocypack::Builder builder;
|
arangodb::velocypack::Builder builder;
|
||||||
|
|
||||||
|
// drop all known links
|
||||||
{
|
{
|
||||||
ReadMutex mutex(_mutex);
|
ReadMutex mutex(_mutex);
|
||||||
SCOPED_LOCK(mutex); // '_meta' and '_trackedCids' can be asynchronously updated
|
SCOPED_LOCK(mutex); // '_meta' and '_trackedCids' can be asynchronously updated
|
||||||
|
@ -1228,13 +1225,14 @@ arangodb::Result IResearchView::dropImpl() {
|
||||||
builder.close();
|
builder.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!updateLinks(collections, *(vocbase()), *this, builder.slice()).ok()) {
|
std::unordered_set<TRI_voc_cid_t> collections;
|
||||||
|
|
||||||
|
if (!updateLinks(collections, vocbase(), *this, builder.slice()).ok()) {
|
||||||
return arangodb::Result(
|
return arangodb::Result(
|
||||||
TRI_ERROR_INTERNAL,
|
TRI_ERROR_INTERNAL,
|
||||||
std::string("failed to remove links while removing IResearch view '") + std::to_string(id()) + "'"
|
std::string("failed to remove links while removing IResearch view '") + std::to_string(id()) + "'"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
{
|
{
|
||||||
WriteMutex mutex(_asyncSelf->_mutex);
|
WriteMutex mutex(_asyncSelf->_mutex);
|
||||||
|
@ -1255,10 +1253,7 @@ arangodb::Result IResearchView::dropImpl() {
|
||||||
SCOPED_LOCK(mutex);
|
SCOPED_LOCK(mutex);
|
||||||
|
|
||||||
collections.insert(_meta._collections.begin(), _meta._collections.end());
|
collections.insert(_meta._collections.begin(), _meta._collections.end());
|
||||||
|
validateLinks(collections, vocbase(), *this);
|
||||||
if (vocbase()) {
|
|
||||||
validateLinks(collections, *(vocbase()), *this);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ArangoDB global consistency check, no known dangling links
|
// ArangoDB global consistency check, no known dangling links
|
||||||
if (!collections.empty()) {
|
if (!collections.empty()) {
|
||||||
|
@ -1491,7 +1486,7 @@ void IResearchView::getPropertiesVPack(
|
||||||
|
|
||||||
_meta.json(builder);
|
_meta.json(builder);
|
||||||
|
|
||||||
if (!vocbase() || forPersistence) {
|
if (forPersistence) {
|
||||||
return; // nothing more to output (persistent configuration does not need links)
|
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
|
// add CIDs of known collections to list
|
||||||
for (auto& entry: _meta._collections) {
|
for (auto& entry: _meta._collections) {
|
||||||
// skip collections missing from vocbase or UserTransaction constructor will throw an exception
|
// 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));
|
collections.emplace_back(std::to_string(entry));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1516,7 +1511,7 @@ void IResearchView::getPropertiesVPack(
|
||||||
|
|
||||||
try {
|
try {
|
||||||
arangodb::transaction::UserTransaction trx(
|
arangodb::transaction::UserTransaction trx(
|
||||||
transaction::StandaloneContext::Create(vocbase()),
|
transaction::StandaloneContext::Create(&vocbase()),
|
||||||
collections, // readCollections
|
collections, // readCollections
|
||||||
EMPTY, // writeCollections
|
EMPTY, // writeCollections
|
||||||
EMPTY, // exclusiveCollections
|
EMPTY, // exclusiveCollections
|
||||||
|
@ -2091,15 +2086,6 @@ arangodb::Result IResearchView::updateProperties(
|
||||||
arangodb::velocypack::Slice const& slice,
|
arangodb::velocypack::Slice const& slice,
|
||||||
bool partialUpdate
|
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;
|
std::string error;
|
||||||
IResearchViewMeta meta;
|
IResearchViewMeta meta;
|
||||||
IResearchViewMeta::Mask mask;
|
IResearchViewMeta::Mask mask;
|
||||||
|
@ -2156,7 +2142,7 @@ arangodb::Result IResearchView::updateProperties(
|
||||||
std::unordered_set<TRI_voc_cid_t> collections;
|
std::unordered_set<TRI_voc_cid_t> collections;
|
||||||
|
|
||||||
if (partialUpdate) {
|
if (partialUpdate) {
|
||||||
return updateLinks(collections, *vocbase, *this, slice.get(LINKS_FIELD));
|
return updateLinks(collections, vocbase(), *this, slice.get(LINKS_FIELD));
|
||||||
}
|
}
|
||||||
|
|
||||||
arangodb::velocypack::Builder builder;
|
arangodb::velocypack::Builder builder;
|
||||||
|
@ -2173,7 +2159,7 @@ arangodb::Result IResearchView::updateProperties(
|
||||||
|
|
||||||
builder.close();
|
builder.close();
|
||||||
|
|
||||||
return updateLinks(collections, *vocbase, *this, builder.slice());
|
return updateLinks(collections, vocbase(), *this, builder.slice());
|
||||||
}
|
}
|
||||||
|
|
||||||
void IResearchView::registerFlushCallback() {
|
void IResearchView::registerFlushCallback() {
|
||||||
|
@ -2267,7 +2253,7 @@ void IResearchView::verifyKnownCollections() {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto cid : cids) {
|
for (auto cid : cids) {
|
||||||
auto collection = vocbase()->lookupCollection(cid);
|
auto collection = vocbase().lookupCollection(cid);
|
||||||
|
|
||||||
if (!collection) {
|
if (!collection) {
|
||||||
// collection no longer exists, drop it and move on
|
// collection no longer exists, drop it and move on
|
||||||
|
|
|
@ -378,11 +378,11 @@ bool Index::Compare(VPackSlice const& lhs, VPackSlice const& rhs) {
|
||||||
|
|
||||||
/// @brief return a contextual string for logging
|
/// @brief return a contextual string for logging
|
||||||
std::string Index::context() const {
|
std::string Index::context() const {
|
||||||
TRI_ASSERT(_collection->vocbase());
|
TRI_ASSERT(_collection);
|
||||||
std::ostringstream result;
|
std::ostringstream result;
|
||||||
|
|
||||||
result << "index { id: " << id() << ", type: " << oldtypeName()
|
result << "index { id: " << id() << ", type: " << oldtypeName()
|
||||||
<< ", collection: " << _collection->vocbase()->name() << "/"
|
<< ", collection: " << _collection->vocbase().name() << "/"
|
||||||
<< _collection->name() << ", unique: " << (_unique ? "true" : "false")
|
<< _collection->name() << ", unique: " << (_unique ? "true" : "false")
|
||||||
<< ", fields: ";
|
<< ", fields: ";
|
||||||
result << "[";
|
result << "[";
|
||||||
|
|
|
@ -231,7 +231,7 @@ void MMFilesCleanupThread::cleanupCollection(arangodb::LogicalCollection* collec
|
||||||
isDeleted = (s == TRI_VOC_COL_STATUS_DELETED);
|
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
|
// the collection was not marked as deleted, but the database was
|
||||||
isDeleted = true;
|
isDeleted = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -178,15 +178,19 @@ arangodb::Result MMFilesCollection::updateProperties(VPackSlice const& slice,
|
||||||
|
|
||||||
arangodb::Result MMFilesCollection::persistProperties() {
|
arangodb::Result MMFilesCollection::persistProperties() {
|
||||||
Result res;
|
Result res;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
VPackBuilder infoBuilder = _logicalCollection->toVelocyPackIgnore(
|
VPackBuilder infoBuilder = _logicalCollection->toVelocyPackIgnore(
|
||||||
{"path", "statusString"}, true, true);
|
{"path", "statusString"}, true, true);
|
||||||
MMFilesCollectionMarker marker(TRI_DF_MARKER_VPACK_CHANGE_COLLECTION,
|
MMFilesCollectionMarker marker(
|
||||||
_logicalCollection->vocbase()->id(),
|
TRI_DF_MARKER_VPACK_CHANGE_COLLECTION,
|
||||||
|
_logicalCollection->vocbase().id(),
|
||||||
_logicalCollection->id(),
|
_logicalCollection->id(),
|
||||||
infoBuilder.slice());
|
infoBuilder.slice()
|
||||||
|
);
|
||||||
MMFilesWalSlotInfoCopy slotInfo =
|
MMFilesWalSlotInfoCopy slotInfo =
|
||||||
MMFilesLogfileManager::instance()->allocateAndWrite(marker, false);
|
MMFilesLogfileManager::instance()->allocateAndWrite(marker, false);
|
||||||
|
|
||||||
res = slotInfo.errorCode;
|
res = slotInfo.errorCode;
|
||||||
} catch (arangodb::basics::Exception const& ex) {
|
} catch (arangodb::basics::Exception const& ex) {
|
||||||
res = ex.code();
|
res = ex.code();
|
||||||
|
@ -575,7 +579,7 @@ bool MMFilesCollection::isVolatile() const { return _isVolatile; }
|
||||||
/// @brief closes an open collection
|
/// @brief closes an open collection
|
||||||
int MMFilesCollection::close() {
|
int MMFilesCollection::close() {
|
||||||
if (!_logicalCollection->deleted() &&
|
if (!_logicalCollection->deleted() &&
|
||||||
!_logicalCollection->vocbase()->isDropped()) {
|
!_logicalCollection->vocbase().isDropped()) {
|
||||||
auto primIdx = primaryIndex();
|
auto primIdx = primaryIndex();
|
||||||
auto idxSize = primIdx->size();
|
auto idxSize = primIdx->size();
|
||||||
|
|
||||||
|
@ -589,7 +593,7 @@ int MMFilesCollection::close() {
|
||||||
"Database")
|
"Database")
|
||||||
->forceSyncProperties();
|
->forceSyncProperties();
|
||||||
engine->changeCollection(
|
engine->changeCollection(
|
||||||
_logicalCollection->vocbase(),
|
&(_logicalCollection->vocbase()),
|
||||||
_logicalCollection->id(),
|
_logicalCollection->id(),
|
||||||
_logicalCollection,
|
_logicalCollection,
|
||||||
doSync
|
doSync
|
||||||
|
@ -1598,7 +1602,7 @@ int MMFilesCollection::fillIndexes(
|
||||||
|
|
||||||
PerformanceLogScope logScope(
|
PerformanceLogScope logScope(
|
||||||
std::string("fill-indexes-document-collection { collection: ") +
|
std::string("fill-indexes-document-collection { collection: ") +
|
||||||
_logicalCollection->vocbase()->name() + "/" + _logicalCollection->name() +
|
_logicalCollection->vocbase().name() + "/" + _logicalCollection->name() +
|
||||||
" }, indexes: " + std::to_string(n - 1));
|
" }, indexes: " + std::to_string(n - 1));
|
||||||
|
|
||||||
auto poster = [](std::function<void()> fn) -> void {
|
auto poster = [](std::function<void()> fn) -> void {
|
||||||
|
@ -1713,15 +1717,15 @@ int MMFilesCollection::fillIndexes(
|
||||||
|
|
||||||
/// @brief opens an existing collection
|
/// @brief opens an existing collection
|
||||||
int MMFilesCollection::openWorker(bool ignoreErrors) {
|
int MMFilesCollection::openWorker(bool ignoreErrors) {
|
||||||
auto vocbase = _logicalCollection->vocbase();
|
auto& vocbase = _logicalCollection->vocbase();
|
||||||
PerformanceLogScope logScope(std::string("open-collection { collection: ") +
|
PerformanceLogScope logScope(std::string("open-collection { collection: ") +
|
||||||
vocbase->name() + "/" +
|
vocbase.name() + "/" +
|
||||||
_logicalCollection->name() + " }");
|
_logicalCollection->name() + " }");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// check for journals and datafiles
|
// check for journals and datafiles
|
||||||
MMFilesEngine* engine = static_cast<MMFilesEngine*>(EngineSelectorFeature::ENGINE);
|
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) {
|
if (res != TRI_ERROR_NO_ERROR) {
|
||||||
LOG_TOPIC(DEBUG, arangodb::Logger::FIXME) << "cannot open '" << path()
|
LOG_TOPIC(DEBUG, arangodb::Logger::FIXME) << "cannot open '" << path()
|
||||||
|
@ -1746,9 +1750,9 @@ int MMFilesCollection::openWorker(bool ignoreErrors) {
|
||||||
void MMFilesCollection::open(bool ignoreErrors) {
|
void MMFilesCollection::open(bool ignoreErrors) {
|
||||||
VPackBuilder builder;
|
VPackBuilder builder;
|
||||||
StorageEngine* engine = EngineSelectorFeature::ENGINE;
|
StorageEngine* engine = EngineSelectorFeature::ENGINE;
|
||||||
auto vocbase = _logicalCollection->vocbase();
|
auto& vocbase = _logicalCollection->vocbase();
|
||||||
auto cid = _logicalCollection->id();
|
auto cid = _logicalCollection->id();
|
||||||
engine->getCollectionInfo(vocbase, cid, builder, true, 0);
|
engine->getCollectionInfo(&vocbase, cid, builder, true, 0);
|
||||||
|
|
||||||
VPackSlice initialCount =
|
VPackSlice initialCount =
|
||||||
builder.slice().get(std::vector<std::string>({"parameters", "count"}));
|
builder.slice().get(std::vector<std::string>({"parameters", "count"}));
|
||||||
|
@ -1760,7 +1764,7 @@ void MMFilesCollection::open(bool ignoreErrors) {
|
||||||
}
|
}
|
||||||
|
|
||||||
PerformanceLogScope logScope(
|
PerformanceLogScope logScope(
|
||||||
std::string("open-document-collection { collection: ") + vocbase->name() +
|
std::string("open-document-collection { collection: ") + vocbase.name() +
|
||||||
"/" + _logicalCollection->name() + " }");
|
"/" + _logicalCollection->name() + " }");
|
||||||
|
|
||||||
int res = openWorker(ignoreErrors);
|
int res = openWorker(ignoreErrors);
|
||||||
|
@ -1773,15 +1777,15 @@ void MMFilesCollection::open(bool ignoreErrors) {
|
||||||
}
|
}
|
||||||
|
|
||||||
arangodb::SingleCollectionTransaction trx(
|
arangodb::SingleCollectionTransaction trx(
|
||||||
arangodb::transaction::StandaloneContext::Create(vocbase), cid,
|
arangodb::transaction::StandaloneContext::Create(&vocbase), cid,
|
||||||
AccessMode::Type::READ);
|
AccessMode::Type::READ);
|
||||||
// the underlying collections must not be locked here because the "load"
|
// 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
|
// routine can be invoked from any other place, e.g. from an AQL query
|
||||||
trx.addHint(transaction::Hints::Hint::LOCK_NEVER);
|
trx.addHint(transaction::Hints::Hint::LOCK_NEVER);
|
||||||
|
|
||||||
{
|
{
|
||||||
PerformanceLogScope logScope(std::string("iterate-markers { collection: ") +
|
PerformanceLogScope logScope(
|
||||||
vocbase->name() + "/" +
|
std::string("iterate-markers { collection: ") + vocbase.name() + "/" +
|
||||||
_logicalCollection->name() + " }");
|
_logicalCollection->name() + " }");
|
||||||
// iterate over all markers of the collection
|
// iterate over all markers of the collection
|
||||||
res = iterateMarkersOnLoad(&trx);
|
res = iterateMarkersOnLoad(&trx);
|
||||||
|
@ -1842,7 +1846,7 @@ void MMFilesCollection::open(bool ignoreErrors) {
|
||||||
->forceSyncProperties();
|
->forceSyncProperties();
|
||||||
StorageEngine* engine = EngineSelectorFeature::ENGINE;
|
StorageEngine* engine = EngineSelectorFeature::ENGINE;
|
||||||
engine->changeCollection(
|
engine->changeCollection(
|
||||||
_logicalCollection->vocbase(),
|
&(_logicalCollection->vocbase()),
|
||||||
_logicalCollection->id(),
|
_logicalCollection->id(),
|
||||||
_logicalCollection,
|
_logicalCollection,
|
||||||
doSync
|
doSync
|
||||||
|
@ -2239,21 +2243,22 @@ int MMFilesCollection::saveIndex(transaction::Methods* trx,
|
||||||
return TRI_ERROR_OUT_OF_MEMORY;
|
return TRI_ERROR_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto vocbase = _logicalCollection->vocbase();
|
auto& vocbase = _logicalCollection->vocbase();
|
||||||
auto collectionId = _logicalCollection->id();
|
auto collectionId = _logicalCollection->id();
|
||||||
VPackSlice data = builder->slice();
|
VPackSlice data = builder->slice();
|
||||||
|
|
||||||
StorageEngine* engine = EngineSelectorFeature::ENGINE;
|
StorageEngine* engine = EngineSelectorFeature::ENGINE;
|
||||||
engine->createIndex(vocbase, collectionId, idx->id(), data);
|
engine->createIndex(&vocbase, collectionId, idx->id(), data);
|
||||||
|
|
||||||
if (!engine->inRecovery()) {
|
if (!engine->inRecovery()) {
|
||||||
// We need to write an index marker
|
// We need to write an index marker
|
||||||
try {
|
try {
|
||||||
MMFilesCollectionMarker marker(TRI_DF_MARKER_VPACK_CREATE_INDEX,
|
MMFilesCollectionMarker marker(
|
||||||
vocbase->id(), collectionId, data);
|
TRI_DF_MARKER_VPACK_CREATE_INDEX, vocbase.id(), collectionId, data
|
||||||
|
);
|
||||||
MMFilesWalSlotInfoCopy slotInfo =
|
MMFilesWalSlotInfoCopy slotInfo =
|
||||||
MMFilesLogfileManager::instance()->allocateAndWrite(marker, false);
|
MMFilesLogfileManager::instance()->allocateAndWrite(marker, false);
|
||||||
|
|
||||||
res = slotInfo.errorCode;
|
res = slotInfo.errorCode;
|
||||||
} catch (arangodb::basics::Exception const& ex) {
|
} catch (arangodb::basics::Exception const& ex) {
|
||||||
LOG_TOPIC(ERR, arangodb::Logger::FIXME) << "cannot save index definition: " << ex.what();
|
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);
|
events::DropIndex("", std::to_string(iid), TRI_ERROR_NO_ERROR);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
auto vocbase = _logicalCollection->vocbase();
|
auto& vocbase = _logicalCollection->vocbase();
|
||||||
|
|
||||||
if (!removeIndex(iid)) {
|
if (!removeIndex(iid)) {
|
||||||
// We tried to remove an index that does not exist
|
// 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();
|
auto cid = _logicalCollection->id();
|
||||||
MMFilesEngine* engine = static_cast<MMFilesEngine*>(EngineSelectorFeature::ENGINE);
|
MMFilesEngine* engine = static_cast<MMFilesEngine*>(EngineSelectorFeature::ENGINE);
|
||||||
engine->dropIndex(vocbase, cid, iid);
|
|
||||||
|
engine->dropIndex(&vocbase, cid, iid);
|
||||||
|
|
||||||
{
|
{
|
||||||
bool const doSync =
|
bool const doSync =
|
||||||
application_features::ApplicationServer::getFeature<DatabaseFeature>(
|
application_features::ApplicationServer::getFeature<DatabaseFeature>(
|
||||||
|
@ -2395,7 +2402,7 @@ bool MMFilesCollection::dropIndex(TRI_idx_iid_t iid) {
|
||||||
markerBuilder.openObject();
|
markerBuilder.openObject();
|
||||||
markerBuilder.add("id", VPackValue(std::to_string(iid)));
|
markerBuilder.add("id", VPackValue(std::to_string(iid)));
|
||||||
markerBuilder.close();
|
markerBuilder.close();
|
||||||
engine->dropIndexWalMarker(vocbase, cid, markerBuilder.slice(), true, res);
|
engine->dropIndexWalMarker(&vocbase, cid, markerBuilder.slice(), true, res);
|
||||||
|
|
||||||
if (res == TRI_ERROR_NO_ERROR) {
|
if (res == TRI_ERROR_NO_ERROR) {
|
||||||
events::DropIndex("", std::to_string(iid), 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()) {
|
if (locker.isLocked()) {
|
||||||
// when we are here, we've got the read lock
|
// when we are here, we've got the read lock
|
||||||
if (useDeadlockDetector) {
|
if (useDeadlockDetector) {
|
||||||
_logicalCollection->vocbase()->_deadlockDetector.addReader(
|
_logicalCollection->vocbase()._deadlockDetector.addReader(
|
||||||
tid, _logicalCollection, wasBlocked);
|
tid, _logicalCollection, wasBlocked);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2496,7 +2503,8 @@ int MMFilesCollection::lockRead(bool useDeadlockDetector, TRI_voc_tid_t tid, dou
|
||||||
if (!wasBlocked) {
|
if (!wasBlocked) {
|
||||||
// insert reader
|
// insert reader
|
||||||
wasBlocked = true;
|
wasBlocked = true;
|
||||||
if (_logicalCollection->vocbase()->_deadlockDetector.setReaderBlocked(
|
|
||||||
|
if (_logicalCollection->vocbase()._deadlockDetector.setReaderBlocked(
|
||||||
tid, _logicalCollection) == TRI_ERROR_DEADLOCK) {
|
tid, _logicalCollection) == TRI_ERROR_DEADLOCK) {
|
||||||
// deadlock
|
// deadlock
|
||||||
LOG_TOPIC(TRACE, arangodb::Logger::FIXME)
|
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
|
// periodically check for deadlocks
|
||||||
TRI_ASSERT(wasBlocked);
|
TRI_ASSERT(wasBlocked);
|
||||||
iterations = 0;
|
iterations = 0;
|
||||||
if (_logicalCollection->vocbase()->_deadlockDetector.detectDeadlock(
|
|
||||||
|
if (_logicalCollection->vocbase()._deadlockDetector.detectDeadlock(
|
||||||
tid, _logicalCollection, false) == TRI_ERROR_DEADLOCK) {
|
tid, _logicalCollection, false) == TRI_ERROR_DEADLOCK) {
|
||||||
// deadlock
|
// deadlock
|
||||||
_logicalCollection->vocbase()->_deadlockDetector.unsetReaderBlocked(
|
_logicalCollection->vocbase()._deadlockDetector.unsetReaderBlocked(
|
||||||
tid, _logicalCollection);
|
tid, _logicalCollection);
|
||||||
LOG_TOPIC(TRACE, arangodb::Logger::FIXME)
|
LOG_TOPIC(TRACE, arangodb::Logger::FIXME)
|
||||||
<< "deadlock detected while trying to acquire read-lock "
|
<< "deadlock detected while trying to acquire read-lock "
|
||||||
|
@ -2528,7 +2537,7 @@ int MMFilesCollection::lockRead(bool useDeadlockDetector, TRI_voc_tid_t tid, dou
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
// clean up!
|
// clean up!
|
||||||
if (wasBlocked) {
|
if (wasBlocked) {
|
||||||
_logicalCollection->vocbase()->_deadlockDetector.unsetReaderBlocked(
|
_logicalCollection->vocbase()._deadlockDetector.unsetReaderBlocked(
|
||||||
tid, _logicalCollection);
|
tid, _logicalCollection);
|
||||||
}
|
}
|
||||||
// always exit
|
// always exit
|
||||||
|
@ -2549,7 +2558,7 @@ int MMFilesCollection::lockRead(bool useDeadlockDetector, TRI_voc_tid_t tid, dou
|
||||||
|
|
||||||
if (now > startTime + timeout) {
|
if (now > startTime + timeout) {
|
||||||
if (useDeadlockDetector) {
|
if (useDeadlockDetector) {
|
||||||
_logicalCollection->vocbase()->_deadlockDetector.unsetReaderBlocked(
|
_logicalCollection->vocbase()._deadlockDetector.unsetReaderBlocked(
|
||||||
tid, _logicalCollection);
|
tid, _logicalCollection);
|
||||||
}
|
}
|
||||||
LOG_TOPIC(TRACE, arangodb::Logger::FIXME)
|
LOG_TOPIC(TRACE, arangodb::Logger::FIXME)
|
||||||
|
@ -2597,7 +2606,7 @@ int MMFilesCollection::lockWrite(bool useDeadlockDetector, TRI_voc_tid_t tid, do
|
||||||
if (locker.isLocked()) {
|
if (locker.isLocked()) {
|
||||||
// register writer
|
// register writer
|
||||||
if (useDeadlockDetector) {
|
if (useDeadlockDetector) {
|
||||||
_logicalCollection->vocbase()->_deadlockDetector.addWriter(
|
_logicalCollection->vocbase()._deadlockDetector.addWriter(
|
||||||
tid, _logicalCollection, wasBlocked);
|
tid, _logicalCollection, wasBlocked);
|
||||||
}
|
}
|
||||||
// keep lock and exit loop
|
// keep lock and exit loop
|
||||||
|
@ -2610,7 +2619,7 @@ int MMFilesCollection::lockWrite(bool useDeadlockDetector, TRI_voc_tid_t tid, do
|
||||||
if (!wasBlocked) {
|
if (!wasBlocked) {
|
||||||
// insert writer
|
// insert writer
|
||||||
wasBlocked = true;
|
wasBlocked = true;
|
||||||
if (_logicalCollection->vocbase()->_deadlockDetector.setWriterBlocked(
|
if (_logicalCollection->vocbase()._deadlockDetector.setWriterBlocked(
|
||||||
tid, _logicalCollection) == TRI_ERROR_DEADLOCK) {
|
tid, _logicalCollection) == TRI_ERROR_DEADLOCK) {
|
||||||
// deadlock
|
// deadlock
|
||||||
LOG_TOPIC(TRACE, arangodb::Logger::FIXME)
|
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
|
// periodically check for deadlocks
|
||||||
TRI_ASSERT(wasBlocked);
|
TRI_ASSERT(wasBlocked);
|
||||||
iterations = 0;
|
iterations = 0;
|
||||||
if (_logicalCollection->vocbase()->_deadlockDetector.detectDeadlock(
|
|
||||||
|
if (_logicalCollection->vocbase()._deadlockDetector.detectDeadlock(
|
||||||
tid, _logicalCollection, true) == TRI_ERROR_DEADLOCK) {
|
tid, _logicalCollection, true) == TRI_ERROR_DEADLOCK) {
|
||||||
// deadlock
|
// deadlock
|
||||||
_logicalCollection->vocbase()->_deadlockDetector.unsetWriterBlocked(
|
_logicalCollection->vocbase()._deadlockDetector.unsetWriterBlocked(
|
||||||
tid, _logicalCollection);
|
tid, _logicalCollection);
|
||||||
LOG_TOPIC(TRACE, arangodb::Logger::FIXME)
|
LOG_TOPIC(TRACE, arangodb::Logger::FIXME)
|
||||||
<< "deadlock detected while trying to acquire "
|
<< "deadlock detected while trying to acquire "
|
||||||
|
@ -2641,7 +2651,7 @@ int MMFilesCollection::lockWrite(bool useDeadlockDetector, TRI_voc_tid_t tid, do
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
// clean up!
|
// clean up!
|
||||||
if (wasBlocked) {
|
if (wasBlocked) {
|
||||||
_logicalCollection->vocbase()->_deadlockDetector.unsetWriterBlocked(
|
_logicalCollection->vocbase()._deadlockDetector.unsetWriterBlocked(
|
||||||
tid, _logicalCollection);
|
tid, _logicalCollection);
|
||||||
}
|
}
|
||||||
// always exit
|
// always exit
|
||||||
|
@ -2662,13 +2672,15 @@ int MMFilesCollection::lockWrite(bool useDeadlockDetector, TRI_voc_tid_t tid, do
|
||||||
|
|
||||||
if (now > startTime + timeout) {
|
if (now > startTime + timeout) {
|
||||||
if (useDeadlockDetector) {
|
if (useDeadlockDetector) {
|
||||||
_logicalCollection->vocbase()->_deadlockDetector.unsetWriterBlocked(
|
_logicalCollection->vocbase()._deadlockDetector.unsetWriterBlocked(
|
||||||
tid, _logicalCollection);
|
tid, _logicalCollection);
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_TOPIC(TRACE, arangodb::Logger::FIXME)
|
LOG_TOPIC(TRACE, arangodb::Logger::FIXME)
|
||||||
<< "timed out after " << timeout
|
<< "timed out after " << timeout
|
||||||
<< " s waiting for write-lock on collection '"
|
<< " s waiting for write-lock on collection '"
|
||||||
<< _logicalCollection->name() << "'";
|
<< _logicalCollection->name() << "'";
|
||||||
|
|
||||||
return TRI_ERROR_LOCK_TIMEOUT;
|
return TRI_ERROR_LOCK_TIMEOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2699,7 +2711,7 @@ int MMFilesCollection::unlockRead(bool useDeadlockDetector, TRI_voc_tid_t tid) {
|
||||||
if (useDeadlockDetector) {
|
if (useDeadlockDetector) {
|
||||||
// unregister reader
|
// unregister reader
|
||||||
try {
|
try {
|
||||||
_logicalCollection->vocbase()->_deadlockDetector.unsetReader(
|
_logicalCollection->vocbase()._deadlockDetector.unsetReader(
|
||||||
tid, _logicalCollection);
|
tid, _logicalCollection);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
}
|
}
|
||||||
|
@ -2729,7 +2741,7 @@ int MMFilesCollection::unlockWrite(bool useDeadlockDetector, TRI_voc_tid_t tid)
|
||||||
if (useDeadlockDetector) {
|
if (useDeadlockDetector) {
|
||||||
// unregister writer
|
// unregister writer
|
||||||
try {
|
try {
|
||||||
_logicalCollection->vocbase()->_deadlockDetector.unsetWriter(
|
_logicalCollection->vocbase()._deadlockDetector.unsetWriter(
|
||||||
tid, _logicalCollection);
|
tid, _logicalCollection);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
// must go on here to unlock the lock
|
// must go on here to unlock the lock
|
||||||
|
@ -3187,7 +3199,7 @@ int MMFilesCollection::detectIndexes(transaction::Methods* trx) {
|
||||||
VPackBuilder builder;
|
VPackBuilder builder;
|
||||||
|
|
||||||
engine->getCollectionInfo(
|
engine->getCollectionInfo(
|
||||||
_logicalCollection->vocbase(),
|
&(_logicalCollection->vocbase()),
|
||||||
_logicalCollection->id(),
|
_logicalCollection->id(),
|
||||||
builder,
|
builder,
|
||||||
true,
|
true,
|
||||||
|
@ -3332,10 +3344,9 @@ Result MMFilesCollection::update(
|
||||||
*builder.get(), options.isRestore, revisionId);
|
*builder.get(), options.isRestore, revisionId);
|
||||||
|
|
||||||
if (_isDBServer) {
|
if (_isDBServer) {
|
||||||
TRI_ASSERT(_logicalCollection->vocbase());
|
|
||||||
// Need to check that no sharding keys have changed:
|
// Need to check that no sharding keys have changed:
|
||||||
if (arangodb::shardKeysChanged(
|
if (arangodb::shardKeysChanged(
|
||||||
_logicalCollection->vocbase()->name(),
|
_logicalCollection->vocbase().name(),
|
||||||
trx->resolver()->getCollectionNameCluster(
|
trx->resolver()->getCollectionNameCluster(
|
||||||
_logicalCollection->planId()
|
_logicalCollection->planId()
|
||||||
),
|
),
|
||||||
|
@ -3471,10 +3482,9 @@ Result MMFilesCollection::replace(
|
||||||
options.isRestore, revisionId);
|
options.isRestore, revisionId);
|
||||||
|
|
||||||
if (_isDBServer) {
|
if (_isDBServer) {
|
||||||
TRI_ASSERT(_logicalCollection->vocbase());
|
|
||||||
// Need to check that no sharding keys have changed:
|
// Need to check that no sharding keys have changed:
|
||||||
if (arangodb::shardKeysChanged(
|
if (arangodb::shardKeysChanged(
|
||||||
_logicalCollection->vocbase()->name(),
|
_logicalCollection->vocbase().name(),
|
||||||
trx->resolver()->getCollectionNameCluster(
|
trx->resolver()->getCollectionNameCluster(
|
||||||
_logicalCollection->planId()
|
_logicalCollection->planId()
|
||||||
),
|
),
|
||||||
|
|
|
@ -65,7 +65,9 @@ void MMFilesCollectionExport::run(uint64_t maxWaitTime, size_t limit) {
|
||||||
MMFilesEngine* engine = static_cast<MMFilesEngine*>(EngineSelectorFeature::ENGINE);
|
MMFilesEngine* engine = static_cast<MMFilesEngine*>(EngineSelectorFeature::ENGINE);
|
||||||
|
|
||||||
// try to acquire the exclusive lock on the compaction
|
// 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
|
// create a ditch under the compaction lock
|
||||||
_ditch = arangodb::MMFilesCollection::toMMFilesCollection(_collection)
|
_ditch = arangodb::MMFilesCollection::toMMFilesCollection(_collection)
|
||||||
->ditches()
|
->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);
|
SingleCollectionTransaction trx(ctx, _name, AccessMode::Type::READ);
|
||||||
|
|
||||||
// already locked by guard above
|
// already locked by guard above
|
||||||
|
|
|
@ -77,7 +77,9 @@ void MMFilesCollectionKeys::create(TRI_voc_tick_t maxTick) {
|
||||||
_collection->id(), 30.0
|
_collection->id(), 30.0
|
||||||
);
|
);
|
||||||
MMFilesEngine* engine = static_cast<MMFilesEngine*>(EngineSelectorFeature::ENGINE);
|
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
|
// create a ditch under the compaction lock
|
||||||
_ditch = arangodb::MMFilesCollection::toMMFilesCollection(_collection)
|
_ditch = arangodb::MMFilesCollection::toMMFilesCollection(_collection)
|
||||||
->ditches()
|
->ditches()
|
||||||
|
@ -93,7 +95,7 @@ void MMFilesCollectionKeys::create(TRI_voc_tick_t maxTick) {
|
||||||
|
|
||||||
// copy all document tokens into the result under the read-lock
|
// 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(
|
SingleCollectionTransaction trx(
|
||||||
ctx, _collection->id(), AccessMode::Type::READ
|
ctx, _collection->id(), AccessMode::Type::READ
|
||||||
);
|
);
|
||||||
|
|
|
@ -753,7 +753,7 @@ int MMFilesCollectorThread::processCollectionOperations(MMFilesCollectorCache* c
|
||||||
}
|
}
|
||||||
|
|
||||||
arangodb::SingleCollectionTransaction trx(
|
arangodb::SingleCollectionTransaction trx(
|
||||||
arangodb::transaction::StandaloneContext::Create(collection->vocbase()),
|
arangodb::transaction::StandaloneContext::Create(&(collection->vocbase())),
|
||||||
collection->id(),
|
collection->id(),
|
||||||
AccessMode::Type::WRITE
|
AccessMode::Type::WRITE
|
||||||
);
|
);
|
||||||
|
|
|
@ -436,7 +436,7 @@ void MMFilesCompactorThread::compactDatafiles(LogicalCollection* collection,
|
||||||
};
|
};
|
||||||
|
|
||||||
arangodb::SingleCollectionTransaction trx(
|
arangodb::SingleCollectionTransaction trx(
|
||||||
arangodb::transaction::StandaloneContext::Create(collection->vocbase()),
|
arangodb::transaction::StandaloneContext::Create(&(collection->vocbase())),
|
||||||
collection->id(),
|
collection->id(),
|
||||||
AccessMode::Type::WRITE
|
AccessMode::Type::WRITE
|
||||||
);
|
);
|
||||||
|
|
|
@ -1619,7 +1619,8 @@ static bool UnloadCollectionCallback(LogicalCollection* collection) {
|
||||||
// as the cleanup thread has already popped the unload ditch from the
|
// as the cleanup thread has already popped the unload ditch from the
|
||||||
// ditches list,
|
// ditches list,
|
||||||
// we need to insert a new one to really execute the unload
|
// we need to insert a new one to really execute the unload
|
||||||
collection->vocbase()->unloadCollection(collection, false);
|
collection->vocbase().unloadCollection(collection, false);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -473,7 +473,7 @@ Result MMFilesPersistentIndex::remove(transaction::Methods* trx,
|
||||||
/// @brief called when the index is dropped
|
/// @brief called when the index is dropped
|
||||||
int MMFilesPersistentIndex::drop() {
|
int MMFilesPersistentIndex::drop() {
|
||||||
return MMFilesPersistentIndexFeature::instance()->dropIndex(
|
return MMFilesPersistentIndexFeature::instance()->dropIndex(
|
||||||
_collection->vocbase()->id(), _collection->id(), _iid
|
_collection->vocbase().id(), _collection->id(), _iid
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ static void JS_RotateVocbaseCol(
|
||||||
}
|
}
|
||||||
|
|
||||||
SingleCollectionTransaction trx(
|
SingleCollectionTransaction trx(
|
||||||
transaction::V8Context::Create(collection->vocbase(), true),
|
transaction::V8Context::Create(&(collection->vocbase()), true),
|
||||||
collection->id(),
|
collection->id(),
|
||||||
AccessMode::Type::WRITE
|
AccessMode::Type::WRITE
|
||||||
);
|
);
|
||||||
|
|
|
@ -110,7 +110,7 @@ void MMFilesWalRecoverState::releaseResources() {
|
||||||
for (auto it = openedCollections.begin(); it != openedCollections.end();
|
for (auto it = openedCollections.begin(); it != openedCollections.end();
|
||||||
++it) {
|
++it) {
|
||||||
arangodb::LogicalCollection* collection = it->second;
|
arangodb::LogicalCollection* collection = it->second;
|
||||||
collection->vocbase()->releaseCollection(collection);
|
collection->vocbase().releaseCollection(collection);
|
||||||
}
|
}
|
||||||
|
|
||||||
openedCollections.clear();
|
openedCollections.clear();
|
||||||
|
@ -162,9 +162,9 @@ TRI_vocbase_t* MMFilesWalRecoverState::releaseDatabase(
|
||||||
|
|
||||||
TRI_ASSERT(collection != nullptr);
|
TRI_ASSERT(collection != nullptr);
|
||||||
|
|
||||||
if (collection->vocbase()->id() == databaseId) {
|
if (collection->vocbase().id() == databaseId) {
|
||||||
// correct database, now release the collection
|
// correct database, now release the collection
|
||||||
TRI_ASSERT(vocbase == collection->vocbase());
|
TRI_ASSERT(vocbase == &(collection->vocbase()));
|
||||||
vocbase->releaseCollection(collection);
|
vocbase->releaseCollection(collection);
|
||||||
// get new iterator position
|
// get new iterator position
|
||||||
it2 = openedCollections.erase(it2);
|
it2 = openedCollections.erase(it2);
|
||||||
|
@ -192,7 +192,7 @@ arangodb::LogicalCollection* MMFilesWalRecoverState::releaseCollection(
|
||||||
arangodb::LogicalCollection* collection = it->second;
|
arangodb::LogicalCollection* collection = it->second;
|
||||||
|
|
||||||
TRI_ASSERT(collection != nullptr);
|
TRI_ASSERT(collection != nullptr);
|
||||||
collection->vocbase()->releaseCollection(collection);
|
collection->vocbase().releaseCollection(collection);
|
||||||
openedCollections.erase(collectionId);
|
openedCollections.erase(collectionId);
|
||||||
|
|
||||||
return collection;
|
return collection;
|
||||||
|
@ -1608,7 +1608,7 @@ int MMFilesWalRecoverState::fillIndexes() {
|
||||||
// activate secondary indexes
|
// activate secondary indexes
|
||||||
physical->useSecondaryIndexes(true);
|
physical->useSecondaryIndexes(true);
|
||||||
|
|
||||||
auto ctx = transaction::StandaloneContext::Create(collection->vocbase());
|
auto ctx = transaction::StandaloneContext::Create(&(collection->vocbase()));
|
||||||
arangodb::SingleCollectionTransaction trx(
|
arangodb::SingleCollectionTransaction trx(
|
||||||
ctx, collection->id(), AccessMode::Type::WRITE
|
ctx, collection->id(), AccessMode::Type::WRITE
|
||||||
);
|
);
|
||||||
|
|
|
@ -465,7 +465,7 @@ int MMFilesDumpCollectionReplication(MMFilesReplicationDumpContext* dump,
|
||||||
res = DumpCollection(
|
res = DumpCollection(
|
||||||
dump,
|
dump,
|
||||||
collection,
|
collection,
|
||||||
collection->vocbase()->id(),
|
collection->vocbase().id(),
|
||||||
collection->id(),
|
collection->id(),
|
||||||
dataMin,
|
dataMin,
|
||||||
dataMax,
|
dataMax,
|
||||||
|
|
|
@ -115,7 +115,7 @@ RocksDBCollection::RocksDBCollection(LogicalCollection* collection,
|
||||||
}
|
}
|
||||||
|
|
||||||
rocksutils::globalRocksEngine()->addCollectionMapping(
|
rocksutils::globalRocksEngine()->addCollectionMapping(
|
||||||
_objectId, _logicalCollection->vocbase()->id(), _logicalCollection->id()
|
_objectId, _logicalCollection->vocbase().id(), _logicalCollection->id()
|
||||||
);
|
);
|
||||||
|
|
||||||
if (_cacheEnabled) {
|
if (_cacheEnabled) {
|
||||||
|
@ -136,7 +136,7 @@ RocksDBCollection::RocksDBCollection(LogicalCollection* collection,
|
||||||
_cacheEnabled(
|
_cacheEnabled(
|
||||||
static_cast<RocksDBCollection const*>(physical)->_cacheEnabled) {
|
static_cast<RocksDBCollection const*>(physical)->_cacheEnabled) {
|
||||||
rocksutils::globalRocksEngine()->addCollectionMapping(
|
rocksutils::globalRocksEngine()->addCollectionMapping(
|
||||||
_objectId, _logicalCollection->vocbase()->id(), _logicalCollection->id()
|
_objectId, _logicalCollection->vocbase().id(), _logicalCollection->id()
|
||||||
);
|
);
|
||||||
|
|
||||||
if (_cacheEnabled) {
|
if (_cacheEnabled) {
|
||||||
|
@ -531,11 +531,11 @@ std::shared_ptr<Index> RocksDBCollection::createIndex(
|
||||||
VPackBuilder indexInfo;
|
VPackBuilder indexInfo;
|
||||||
idx->toVelocyPack(indexInfo, false, true);
|
idx->toVelocyPack(indexInfo, false, true);
|
||||||
res = static_cast<RocksDBEngine*>(engine)->writeCreateCollectionMarker(
|
res = static_cast<RocksDBEngine*>(engine)->writeCreateCollectionMarker(
|
||||||
_logicalCollection->vocbase()->id(),
|
_logicalCollection->vocbase().id(),
|
||||||
_logicalCollection->id(),
|
_logicalCollection->id(),
|
||||||
builder.slice(),
|
builder.slice(),
|
||||||
RocksDBLogValue::IndexCreate(
|
RocksDBLogValue::IndexCreate(
|
||||||
_logicalCollection->vocbase()->id(),
|
_logicalCollection->vocbase().id(),
|
||||||
_logicalCollection->id(),
|
_logicalCollection->id(),
|
||||||
indexInfo.slice()
|
indexInfo.slice()
|
||||||
)
|
)
|
||||||
|
@ -618,11 +618,11 @@ int RocksDBCollection::restoreIndex(transaction::Methods* trx,
|
||||||
static_cast<RocksDBEngine*>(EngineSelectorFeature::ENGINE);
|
static_cast<RocksDBEngine*>(EngineSelectorFeature::ENGINE);
|
||||||
TRI_ASSERT(engine != nullptr);
|
TRI_ASSERT(engine != nullptr);
|
||||||
int res = engine->writeCreateCollectionMarker(
|
int res = engine->writeCreateCollectionMarker(
|
||||||
_logicalCollection->vocbase()->id(),
|
_logicalCollection->vocbase().id(),
|
||||||
_logicalCollection->id(),
|
_logicalCollection->id(),
|
||||||
builder.slice(),
|
builder.slice(),
|
||||||
RocksDBLogValue::IndexCreate(
|
RocksDBLogValue::IndexCreate(
|
||||||
_logicalCollection->vocbase()->id(),
|
_logicalCollection->vocbase().id(),
|
||||||
_logicalCollection->id(),
|
_logicalCollection->id(),
|
||||||
indexInfo.slice()
|
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
|
// log this event in the WAL and in the collection meta-data
|
||||||
int res = engine->writeCreateCollectionMarker(
|
int res = engine->writeCreateCollectionMarker(
|
||||||
_logicalCollection->vocbase()->id(),
|
_logicalCollection->vocbase().id(),
|
||||||
_logicalCollection->id(),
|
_logicalCollection->id(),
|
||||||
builder.slice(),
|
builder.slice(),
|
||||||
RocksDBLogValue::IndexDrop(
|
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.mergeObjects, options.keepNull, *builder.get(),
|
||||||
options.isRestore, revisionId);
|
options.isRestore, revisionId);
|
||||||
if (_isDBServer) {
|
if (_isDBServer) {
|
||||||
TRI_ASSERT(_logicalCollection->vocbase());
|
|
||||||
// Need to check that no sharding keys have changed:
|
// Need to check that no sharding keys have changed:
|
||||||
if (arangodb::shardKeysChanged(
|
if (arangodb::shardKeysChanged(
|
||||||
_logicalCollection->vocbase()->name(),
|
_logicalCollection->vocbase().name(),
|
||||||
trx->resolver()->getCollectionNameCluster(
|
trx->resolver()->getCollectionNameCluster(
|
||||||
_logicalCollection->planId()
|
_logicalCollection->planId()
|
||||||
),
|
),
|
||||||
|
@ -1136,10 +1135,9 @@ Result RocksDBCollection::replace(transaction::Methods* trx,
|
||||||
revisionId);
|
revisionId);
|
||||||
|
|
||||||
if (_isDBServer) {
|
if (_isDBServer) {
|
||||||
TRI_ASSERT(_logicalCollection->vocbase());
|
|
||||||
// Need to check that no sharding keys have changed:
|
// Need to check that no sharding keys have changed:
|
||||||
if (arangodb::shardKeysChanged(
|
if (arangodb::shardKeysChanged(
|
||||||
_logicalCollection->vocbase()->name(),
|
_logicalCollection->vocbase().name(),
|
||||||
trx->resolver()->getCollectionNameCluster(
|
trx->resolver()->getCollectionNameCluster(
|
||||||
_logicalCollection->planId()
|
_logicalCollection->planId()
|
||||||
),
|
),
|
||||||
|
@ -1360,12 +1358,12 @@ int RocksDBCollection::saveIndex(transaction::Methods* trx,
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<VPackBuilder> builder = idx->toVelocyPack(false, true);
|
std::shared_ptr<VPackBuilder> builder = idx->toVelocyPack(false, true);
|
||||||
auto vocbase = _logicalCollection->vocbase();
|
auto& vocbase = _logicalCollection->vocbase();
|
||||||
auto collectionId = _logicalCollection->id();
|
auto collectionId = _logicalCollection->id();
|
||||||
VPackSlice data = builder->slice();
|
VPackSlice data = builder->slice();
|
||||||
|
|
||||||
StorageEngine* engine = EngineSelectorFeature::ENGINE;
|
StorageEngine* engine = EngineSelectorFeature::ENGINE;
|
||||||
engine->createIndex(vocbase, collectionId, idx->id(), data);
|
engine->createIndex(&vocbase, collectionId, idx->id(), data);
|
||||||
|
|
||||||
return TRI_ERROR_NO_ERROR;
|
return TRI_ERROR_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -1854,7 +1852,8 @@ int RocksDBCollection::unlockRead() {
|
||||||
// rescans the collection to update document count
|
// rescans the collection to update document count
|
||||||
uint64_t RocksDBCollection::recalculateCounts() {
|
uint64_t RocksDBCollection::recalculateCounts() {
|
||||||
// start transaction to get a collection lock
|
// start transaction to get a collection lock
|
||||||
auto ctx = transaction::StandaloneContext::Create(_logicalCollection->vocbase());
|
auto ctx =
|
||||||
|
transaction::StandaloneContext::Create(&(_logicalCollection->vocbase()));
|
||||||
SingleCollectionTransaction trx(
|
SingleCollectionTransaction trx(
|
||||||
ctx, _logicalCollection->id(), AccessMode::Type::EXCLUSIVE
|
ctx, _logicalCollection->id(), AccessMode::Type::EXCLUSIVE
|
||||||
);
|
);
|
||||||
|
@ -1988,7 +1987,8 @@ void RocksDBCollection::recalculateIndexEstimates(
|
||||||
// method or endpoint unless the implementation changes
|
// method or endpoint unless the implementation changes
|
||||||
|
|
||||||
// start transaction to get a collection lock
|
// start transaction to get a collection lock
|
||||||
auto ctx = transaction::StandaloneContext::Create(_logicalCollection->vocbase());
|
auto ctx =
|
||||||
|
transaction::StandaloneContext::Create(&(_logicalCollection->vocbase()));
|
||||||
arangodb::SingleCollectionTransaction trx(
|
arangodb::SingleCollectionTransaction trx(
|
||||||
ctx, _logicalCollection->id(), AccessMode::Type::EXCLUSIVE
|
ctx, _logicalCollection->id(), AccessMode::Type::EXCLUSIVE
|
||||||
);
|
);
|
||||||
|
|
|
@ -67,7 +67,7 @@ RocksDBIndex::RocksDBIndex(
|
||||||
RocksDBEngine* engine = static_cast<RocksDBEngine*>(EngineSelectorFeature::ENGINE);
|
RocksDBEngine* engine = static_cast<RocksDBEngine*>(EngineSelectorFeature::ENGINE);
|
||||||
|
|
||||||
engine->addIndexMapping(
|
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);
|
RocksDBEngine* engine = static_cast<RocksDBEngine*>(EngineSelectorFeature::ENGINE);
|
||||||
|
|
||||||
engine->addIndexMapping(
|
engine->addIndexMapping(
|
||||||
_objectId, collection->vocbase()->id(), collection->id(), _iid
|
_objectId, collection->vocbase().id(), collection->id(), _iid
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -290,9 +290,8 @@ std::string CollectionNameResolver::localNameLookup(TRI_voc_cid_t cid) const {
|
||||||
std::shared_ptr<LogicalCollection> ci;
|
std::shared_ptr<LogicalCollection> ci;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
TRI_ASSERT(it->second->vocbase());
|
|
||||||
ci = ClusterInfo::instance()->getCollection(
|
ci = ClusterInfo::instance()->getCollection(
|
||||||
it->second->vocbase()->name(), name
|
it->second->vocbase().name(), name
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
|
|
|
@ -77,7 +77,7 @@ static void WeakCollectionCallback(const v8::WeakCallbackInfo<
|
||||||
v8g->decreaseActiveExternals();
|
v8g->decreaseActiveExternals();
|
||||||
|
|
||||||
// decrease the reference-counter for the database
|
// decrease the reference-counter for the database
|
||||||
TRI_ASSERT(!collection->vocbase()->isDangling());
|
TRI_ASSERT(!collection->vocbase().isDangling());
|
||||||
|
|
||||||
// find the persistent handle
|
// find the persistent handle
|
||||||
#if ARANGODB_ENABLE_MAINTAINER_MODE
|
#if ARANGODB_ENABLE_MAINTAINER_MODE
|
||||||
|
@ -90,10 +90,10 @@ static void WeakCollectionCallback(const v8::WeakCallbackInfo<
|
||||||
v8g->JSCollections.erase(collection);
|
v8g->JSCollections.erase(collection);
|
||||||
|
|
||||||
if (!collection->isLocal()) {
|
if (!collection->isLocal()) {
|
||||||
collection->vocbase()->release();
|
collection->vocbase().release();
|
||||||
delete collection;
|
delete collection;
|
||||||
} else {
|
} else {
|
||||||
collection->vocbase()->release();
|
collection->vocbase().release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,8 +125,9 @@ v8::Handle<v8::Object> WrapCollection(v8::Isolate* isolate,
|
||||||
|
|
||||||
if (it == v8g->JSCollections.end()) {
|
if (it == v8g->JSCollections.end()) {
|
||||||
// increase the reference-counter for the database
|
// increase the reference-counter for the database
|
||||||
TRI_ASSERT(!nonconstCollection->vocbase()->isDangling());
|
TRI_ASSERT(!nonconstCollection->vocbase().isDangling());
|
||||||
nonconstCollection->vocbase()->forceUse();
|
nonconstCollection->vocbase().forceUse();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
auto externalCollection = v8::External::New(isolate, nonconstCollection);
|
auto externalCollection = v8::External::New(isolate, nonconstCollection);
|
||||||
|
|
||||||
|
@ -138,7 +139,7 @@ v8::Handle<v8::Object> WrapCollection(v8::Isolate* isolate,
|
||||||
v8::WeakCallbackType::kFinalizer);
|
v8::WeakCallbackType::kFinalizer);
|
||||||
v8g->increaseActiveExternals();
|
v8g->increaseActiveExternals();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
nonconstCollection->vocbase()->release();
|
nonconstCollection->vocbase().release();
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -154,7 +155,7 @@ v8::Handle<v8::Object> WrapCollection(v8::Isolate* isolate,
|
||||||
TRI_V8UInt64String<TRI_voc_cid_t>(isolate, collection->id()),
|
TRI_V8UInt64String<TRI_voc_cid_t>(isolate, collection->id()),
|
||||||
v8::ReadOnly
|
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(
|
result->ForceSet(
|
||||||
VersionKeyHidden,
|
VersionKeyHidden,
|
||||||
v8::Integer::NewFromUnsigned(isolate, 5),
|
v8::Integer::NewFromUnsigned(isolate, 5),
|
||||||
|
|
|
@ -310,7 +310,7 @@ static void ExistsVocbaseVPack(
|
||||||
TRI_V8_THROW_EXCEPTION_INTERNAL("cannot extract collection");
|
TRI_V8_THROW_EXCEPTION_INTERNAL("cannot extract collection");
|
||||||
}
|
}
|
||||||
|
|
||||||
vocbase = col->vocbase();
|
vocbase = &(col->vocbase());
|
||||||
} else {
|
} else {
|
||||||
// called as db._exists()
|
// called as db._exists()
|
||||||
vocbase = GetContextVocBase(isolate);
|
vocbase = GetContextVocBase(isolate);
|
||||||
|
@ -403,11 +403,8 @@ static void DocumentVocbaseCol(
|
||||||
if (col == nullptr) {
|
if (col == nullptr) {
|
||||||
TRI_V8_THROW_EXCEPTION_INTERNAL("cannot extract collection");
|
TRI_V8_THROW_EXCEPTION_INTERNAL("cannot extract collection");
|
||||||
}
|
}
|
||||||
TRI_vocbase_t* vocbase = col->vocbase();
|
|
||||||
collectionName = col->name();
|
collectionName = col->name();
|
||||||
if (vocbase == nullptr) {
|
|
||||||
TRI_V8_THROW_EXCEPTION(TRI_ERROR_ARANGO_DATABASE_NOT_FOUND);
|
|
||||||
}
|
|
||||||
|
|
||||||
VPackBuilder searchBuilder;
|
VPackBuilder searchBuilder;
|
||||||
|
|
||||||
|
@ -437,11 +434,11 @@ static void DocumentVocbaseCol(
|
||||||
}
|
}
|
||||||
|
|
||||||
VPackSlice search = searchBuilder.slice();
|
VPackSlice search = searchBuilder.slice();
|
||||||
|
auto transactionContext =
|
||||||
auto transactionContext = std::make_shared<transaction::V8Context>(vocbase, true);
|
std::make_shared<transaction::V8Context>(&(col->vocbase()), true);
|
||||||
|
|
||||||
SingleCollectionTransaction trx(transactionContext, collectionName,
|
SingleCollectionTransaction trx(transactionContext, collectionName,
|
||||||
AccessMode::Type::READ);
|
AccessMode::Type::READ);
|
||||||
|
|
||||||
if (!args[0]->IsArray()) {
|
if (!args[0]->IsArray()) {
|
||||||
trx.addHint(transaction::Hints::Hint::SINGLE_OPERATION);
|
trx.addHint(transaction::Hints::Hint::SINGLE_OPERATION);
|
||||||
}
|
}
|
||||||
|
@ -605,13 +602,8 @@ static void RemoveVocbaseCol(v8::FunctionCallbackInfo<v8::Value> const& args) {
|
||||||
if (col == nullptr) {
|
if (col == nullptr) {
|
||||||
TRI_V8_THROW_EXCEPTION_INTERNAL("cannot extract collection");
|
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();
|
std::string collectionName = col->name();
|
||||||
|
|
||||||
VPackBuilder searchBuilder;
|
VPackBuilder searchBuilder;
|
||||||
|
|
||||||
auto workOnOneDocument = [&](v8::Local<v8::Value> const searchValue, bool isBabies) {
|
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();
|
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);
|
SingleCollectionTransaction trx(transactionContext, collectionName, AccessMode::Type::WRITE);
|
||||||
|
|
||||||
if (!args[0]->IsArray()) {
|
if (!args[0]->IsArray()) {
|
||||||
trx.addHint(transaction::Hints::Hint::SINGLE_OPERATION);
|
trx.addHint(transaction::Hints::Hint::SINGLE_OPERATION);
|
||||||
}
|
}
|
||||||
|
@ -818,12 +812,6 @@ static void JS_BinaryDocumentVocbaseCol(
|
||||||
TRI_V8_THROW_EXCEPTION_INTERNAL("cannot extract collection");
|
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;
|
VPackBuilder searchBuilder;
|
||||||
v8::Local<v8::Value> const searchValue = args[0];
|
v8::Local<v8::Value> const searchValue = args[0];
|
||||||
collectionName = col->name();
|
collectionName = col->name();
|
||||||
|
@ -843,10 +831,8 @@ static void JS_BinaryDocumentVocbaseCol(
|
||||||
}
|
}
|
||||||
|
|
||||||
VPackSlice search = searchBuilder.slice();
|
VPackSlice search = searchBuilder.slice();
|
||||||
|
|
||||||
auto transactionContext =
|
auto transactionContext =
|
||||||
std::make_shared<transaction::V8Context>(vocbase, true);
|
std::make_shared<transaction::V8Context>(&(col->vocbase()), true);
|
||||||
|
|
||||||
SingleCollectionTransaction trx(transactionContext, collectionName,
|
SingleCollectionTransaction trx(transactionContext, collectionName,
|
||||||
AccessMode::Type::READ);
|
AccessMode::Type::READ);
|
||||||
|
|
||||||
|
@ -994,7 +980,7 @@ static void JS_FiguresVocbaseCol(
|
||||||
}
|
}
|
||||||
|
|
||||||
SingleCollectionTransaction trx(
|
SingleCollectionTransaction trx(
|
||||||
transaction::V8Context::Create(collection->vocbase(), true),
|
transaction::V8Context::Create(&(collection->vocbase()), true),
|
||||||
collection->id(),
|
collection->id(),
|
||||||
AccessMode::Type::READ
|
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_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();
|
std::string collectionName = v8Collection->name();
|
||||||
auto collection = vocbase->lookupCollection(collectionName);
|
auto collection = v8Collection->vocbase().lookupCollection(collectionName);
|
||||||
|
|
||||||
if (collection == nullptr) {
|
if (collection == nullptr) {
|
||||||
TRI_V8_THROW_EXCEPTION(TRI_ERROR_ARANGO_DATA_SOURCE_NOT_FOUND);
|
TRI_V8_THROW_EXCEPTION(TRI_ERROR_ARANGO_DATA_SOURCE_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string theLeader;
|
std::string theLeader;
|
||||||
|
|
||||||
if (args.Length() >= 1 && args[0]->IsString()) {
|
if (args.Length() >= 1 && args[0]->IsString()) {
|
||||||
TRI_Utf8ValueNFC l(args[0]);
|
TRI_Utf8ValueNFC l(args[0]);
|
||||||
theLeader = std::string(*l, l.length());
|
theLeader = std::string(*l, l.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
collection->followers()->setTheLeader(theLeader);
|
collection->followers()->setTheLeader(theLeader);
|
||||||
|
|
||||||
if (theLeader.empty()) {
|
if (theLeader.empty()) {
|
||||||
collection->followers()->clear();
|
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_V8_THROW_EXCEPTION_INTERNAL("cannot extract collection");
|
||||||
}
|
}
|
||||||
|
|
||||||
TRI_vocbase_t* vocbase = collection->vocbase();
|
|
||||||
std::string collectionName = collection->name();
|
std::string collectionName = collection->name();
|
||||||
if (vocbase == nullptr) {
|
auto realCollection =
|
||||||
TRI_V8_THROW_EXCEPTION(TRI_ERROR_ARANGO_DATABASE_NOT_FOUND);
|
collection->vocbase().lookupCollection(collectionName);
|
||||||
}
|
|
||||||
|
|
||||||
auto realCollection = vocbase->lookupCollection(collectionName);
|
|
||||||
if (realCollection == nullptr) {
|
if (realCollection == nullptr) {
|
||||||
TRI_V8_THROW_EXCEPTION(TRI_ERROR_ARANGO_DATA_SOURCE_NOT_FOUND);
|
TRI_V8_THROW_EXCEPTION(TRI_ERROR_ARANGO_DATA_SOURCE_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
theLeader = realCollection->followers()->getLeader();
|
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_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();
|
std::string collectionName = v8Collection->name();
|
||||||
auto collection = vocbase->lookupCollection(collectionName);
|
auto collection = v8Collection->vocbase().lookupCollection(collectionName);
|
||||||
|
|
||||||
if (collection == nullptr) {
|
if (collection == nullptr) {
|
||||||
TRI_V8_THROW_EXCEPTION(TRI_ERROR_ARANGO_DATA_SOURCE_NOT_FOUND);
|
TRI_V8_THROW_EXCEPTION(TRI_ERROR_ARANGO_DATA_SOURCE_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
collection->followers()->remove(serverId);
|
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_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();
|
std::string collectionName = v8Collection->name();
|
||||||
auto collection = vocbase->lookupCollection(collectionName);
|
auto collection = v8Collection->vocbase().lookupCollection(collectionName);
|
||||||
|
|
||||||
if (collection == nullptr) {
|
if (collection == nullptr) {
|
||||||
TRI_V8_THROW_EXCEPTION(TRI_ERROR_ARANGO_DATA_SOURCE_NOT_FOUND);
|
TRI_V8_THROW_EXCEPTION(TRI_ERROR_ARANGO_DATA_SOURCE_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<arangodb::FollowerInfo> const& followerInfo = collection->followers();
|
std::unique_ptr<arangodb::FollowerInfo> const& followerInfo = collection->followers();
|
||||||
std::shared_ptr<std::vector<ServerID> const> followers = followerInfo->get();
|
std::shared_ptr<std::vector<ServerID> const> followers = followerInfo->get();
|
||||||
uint32_t i = 0;
|
uint32_t i = 0;
|
||||||
|
|
||||||
for (auto const& n : *followers) {
|
for (auto const& n : *followers) {
|
||||||
list->Set(i++, TRI_V8_STD_STRING(isolate, n));
|
list->Set(i++, TRI_V8_STD_STRING(isolate, n));
|
||||||
}
|
}
|
||||||
|
@ -1369,7 +1348,6 @@ static void JS_PropertiesVocbaseCol(
|
||||||
if (consoleColl == nullptr) {
|
if (consoleColl == nullptr) {
|
||||||
TRI_V8_THROW_EXCEPTION_INTERNAL("cannot extract collection");
|
TRI_V8_THROW_EXCEPTION_INTERNAL("cannot extract collection");
|
||||||
}
|
}
|
||||||
TRI_vocbase_t* vocbase = consoleColl->vocbase();
|
|
||||||
|
|
||||||
bool const isModification = (args.Length() != 0);
|
bool const isModification = (args.Length() != 0);
|
||||||
if (isModification) {
|
if (isModification) {
|
||||||
|
@ -1394,7 +1372,9 @@ static void JS_PropertiesVocbaseCol(
|
||||||
// in the cluster the collection object might contain outdated
|
// in the cluster the collection object might contain outdated
|
||||||
// properties, which will break tests. We need an extra lookup
|
// properties, which will break tests. We need an extra lookup
|
||||||
VPackBuilder builder;
|
VPackBuilder builder;
|
||||||
methods::Collections::lookup(vocbase, consoleColl->name(),
|
methods::Collections::lookup(
|
||||||
|
&(consoleColl->vocbase()),
|
||||||
|
consoleColl->name(),
|
||||||
[&](LogicalCollection* coll) {
|
[&](LogicalCollection* coll) {
|
||||||
VPackObjectBuilder object(&builder, true);
|
VPackObjectBuilder object(&builder, true);
|
||||||
Result res = methods::Collections::properties(coll, builder);
|
Result res = methods::Collections::properties(coll, builder);
|
||||||
|
@ -1587,15 +1567,9 @@ static void ModifyVocbaseCol(TRI_voc_document_operation_e operation,
|
||||||
if (col == nullptr) {
|
if (col == nullptr) {
|
||||||
TRI_V8_THROW_EXCEPTION_INTERNAL("cannot extract collection");
|
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();
|
std::string collectionName = col->name();
|
||||||
|
|
||||||
VPackBuilder updateBuilder;
|
VPackBuilder updateBuilder;
|
||||||
|
|
||||||
auto workOnOneSearchVal = [&](v8::Local<v8::Value> const searchVal, bool isBabies) {
|
auto workOnOneSearchVal = [&](v8::Local<v8::Value> const searchVal, bool isBabies) {
|
||||||
std::string collName;
|
std::string collName;
|
||||||
if (!ExtractDocumentHandle(isolate, searchVal, collName,
|
if (!ExtractDocumentHandle(isolate, searchVal, collName,
|
||||||
|
@ -1672,7 +1646,8 @@ static void ModifyVocbaseCol(TRI_voc_document_operation_e operation,
|
||||||
VPackSlice const update = updateBuilder.slice();
|
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:
|
// Now start the transaction:
|
||||||
SingleCollectionTransaction trx(transactionContext, collectionName,
|
SingleCollectionTransaction trx(transactionContext, collectionName,
|
||||||
|
@ -2111,8 +2086,10 @@ static void JS_RevisionVocbaseCol(
|
||||||
}
|
}
|
||||||
|
|
||||||
TRI_voc_rid_t revisionId;
|
TRI_voc_rid_t revisionId;
|
||||||
Result res = methods::Collections::revisionId(collection->vocbase(),
|
auto res = methods::Collections::revisionId(
|
||||||
collection, revisionId);
|
&(collection->vocbase()), collection, revisionId
|
||||||
|
);
|
||||||
|
|
||||||
if (res.fail()) {
|
if (res.fail()) {
|
||||||
TRI_V8_THROW_EXCEPTION(res);
|
TRI_V8_THROW_EXCEPTION(res);
|
||||||
}
|
}
|
||||||
|
@ -2277,7 +2254,7 @@ static void InsertVocbaseCol(v8::Isolate* isolate,
|
||||||
|
|
||||||
// load collection
|
// load collection
|
||||||
auto transactionContext =
|
auto transactionContext =
|
||||||
std::make_shared<transaction::V8Context>(collection->vocbase(), true);
|
std::make_shared<transaction::V8Context>(&(collection->vocbase()), true);
|
||||||
SingleCollectionTransaction trx(
|
SingleCollectionTransaction trx(
|
||||||
transactionContext, collection->id(), AccessMode::Type::WRITE
|
transactionContext, collection->id(), AccessMode::Type::WRITE
|
||||||
);
|
);
|
||||||
|
@ -2387,8 +2364,7 @@ static void JS_StatusVocbaseCol(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ServerState::instance()->isCoordinator()) {
|
if (ServerState::instance()->isCoordinator()) {
|
||||||
TRI_ASSERT(collection->vocbase());
|
auto& databaseName = collection->vocbase().name();
|
||||||
auto& databaseName = collection->vocbase()->name();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
std::shared_ptr<LogicalCollection> const ci =
|
std::shared_ptr<LogicalCollection> const ci =
|
||||||
|
@ -2428,7 +2404,7 @@ static void JS_TruncateVocbaseCol(
|
||||||
TRI_V8_THROW_EXCEPTION_INTERNAL("cannot extract collection");
|
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(
|
SingleCollectionTransaction trx(
|
||||||
ctx, collection->id(), AccessMode::Type::EXCLUSIVE
|
ctx, collection->id(), AccessMode::Type::EXCLUSIVE
|
||||||
);
|
);
|
||||||
|
@ -2469,8 +2445,7 @@ static void JS_TypeVocbaseCol(v8::FunctionCallbackInfo<v8::Value> const& args) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ServerState::instance()->isCoordinator()) {
|
if (ServerState::instance()->isCoordinator()) {
|
||||||
TRI_ASSERT(collection->vocbase());
|
auto& databaseName = collection->vocbase().name();
|
||||||
auto& databaseName = collection->vocbase()->name();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
std::shared_ptr<LogicalCollection> const ci =
|
std::shared_ptr<LogicalCollection> const ci =
|
||||||
|
@ -2507,7 +2482,8 @@ static void JS_UnloadVocbaseCol(
|
||||||
TRI_V8_THROW_EXCEPTION_INTERNAL("cannot extract collection");
|
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()) {
|
if (res.fail()) {
|
||||||
TRI_V8_THROW_EXCEPTION(res);
|
TRI_V8_THROW_EXCEPTION(res);
|
||||||
}
|
}
|
||||||
|
@ -2803,21 +2779,19 @@ static void JS_CountVocbaseCol(
|
||||||
details = TRI_ObjectToBoolean(args[0]);
|
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());
|
std::string collectionName(col->name());
|
||||||
|
SingleCollectionTransaction trx(
|
||||||
SingleCollectionTransaction trx(transaction::V8Context::Create(vocbase, true), collectionName, AccessMode::Type::READ);
|
transaction::V8Context::Create(&(col->vocbase()), true),
|
||||||
|
collectionName,
|
||||||
|
AccessMode::Type::READ
|
||||||
|
);
|
||||||
|
|
||||||
if (CollectionLockState::_noLockHeaders != nullptr) {
|
if (CollectionLockState::_noLockHeaders != nullptr) {
|
||||||
if (CollectionLockState::_noLockHeaders->find(collectionName) != CollectionLockState::_noLockHeaders->end()) {
|
if (CollectionLockState::_noLockHeaders->find(collectionName) != CollectionLockState::_noLockHeaders->end()) {
|
||||||
trx.addHint(transaction::Hints::Hint::LOCK_NEVER);
|
trx.addHint(transaction::Hints::Hint::LOCK_NEVER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Result res = trx.begin();
|
Result res = trx.begin();
|
||||||
|
|
||||||
if (!res.ok()) {
|
if (!res.ok()) {
|
||||||
|
@ -2860,8 +2834,8 @@ static void JS_WarmupVocbaseCol(
|
||||||
TRI_V8_THROW_EXCEPTION_INTERNAL("cannot extract collection");
|
TRI_V8_THROW_EXCEPTION_INTERNAL("cannot extract collection");
|
||||||
}
|
}
|
||||||
|
|
||||||
TRI_vocbase_t* vocbase = collection->vocbase();
|
auto res = methods::Collections::warmup(&(collection->vocbase()), collection);
|
||||||
Result res = methods::Collections::warmup(vocbase, collection);
|
|
||||||
if (res.fail()) {
|
if (res.fail()) {
|
||||||
TRI_V8_THROW_EXCEPTION(res);
|
TRI_V8_THROW_EXCEPTION(res);
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,9 +61,14 @@ aql::QueryResultV8 AqlQuery(
|
||||||
TRI_ASSERT(col != nullptr);
|
TRI_ASSERT(col != nullptr);
|
||||||
|
|
||||||
TRI_GET_GLOBALS();
|
TRI_GET_GLOBALS();
|
||||||
arangodb::aql::Query query(true, col->vocbase(), arangodb::aql::QueryString(aql),
|
arangodb::aql::Query query(
|
||||||
bindVars, nullptr, arangodb::aql::PART_MAIN);
|
true,
|
||||||
|
&(col->vocbase()),
|
||||||
|
arangodb::aql::QueryString(aql),
|
||||||
|
bindVars,
|
||||||
|
nullptr,
|
||||||
|
arangodb::aql::PART_MAIN
|
||||||
|
);
|
||||||
auto queryResult = query.executeV8(
|
auto queryResult = query.executeV8(
|
||||||
isolate, static_cast<arangodb::aql::QueryRegistry*>(v8g->_queryRegistry));
|
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::string const collectionName(collection->name());
|
||||||
|
|
||||||
std::shared_ptr<transaction::V8Context> transactionContext =
|
std::shared_ptr<transaction::V8Context> transactionContext =
|
||||||
transaction::V8Context::Create(collection->vocbase(), true);
|
transaction::V8Context::Create(&(collection->vocbase()), true);
|
||||||
SingleCollectionTransaction trx(
|
SingleCollectionTransaction trx(
|
||||||
transactionContext, collection->id(), AccessMode::Type::READ
|
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::string const collectionName(col->name());
|
||||||
|
|
||||||
std::shared_ptr<transaction::V8Context> transactionContext =
|
std::shared_ptr<transaction::V8Context> transactionContext =
|
||||||
transaction::V8Context::Create(col->vocbase(), true);
|
transaction::V8Context::Create(&(col->vocbase()), true);
|
||||||
SingleCollectionTransaction trx(
|
SingleCollectionTransaction trx(
|
||||||
transactionContext, col->id(), AccessMode::Type::READ
|
transactionContext, col->id(), AccessMode::Type::READ
|
||||||
);
|
);
|
||||||
|
|
|
@ -66,7 +66,7 @@ static void WeakViewCallback(
|
||||||
v8g->decreaseActiveExternals();
|
v8g->decreaseActiveExternals();
|
||||||
|
|
||||||
// decrease the reference-counter for the database
|
// decrease the reference-counter for the database
|
||||||
TRI_ASSERT(!view->vocbase()->isDangling());
|
TRI_ASSERT(!view->vocbase().isDangling());
|
||||||
|
|
||||||
// find the persistent handle
|
// find the persistent handle
|
||||||
#if ARANGODB_ENABLE_MAINTAINER_MODE
|
#if ARANGODB_ENABLE_MAINTAINER_MODE
|
||||||
|
@ -78,7 +78,7 @@ static void WeakViewCallback(
|
||||||
v8g->JSViews[view].Reset();
|
v8g->JSViews[view].Reset();
|
||||||
v8g->JSViews.erase(view);
|
v8g->JSViews.erase(view);
|
||||||
|
|
||||||
view->vocbase()->release();
|
view->vocbase().release();
|
||||||
delete v; // delete the shared_ptr on the heap
|
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()) {
|
if (it == v8g->JSViews.end()) {
|
||||||
// increase the reference-counter for the database
|
// increase the reference-counter for the database
|
||||||
TRI_ASSERT(!view->vocbase()->isDangling());
|
TRI_ASSERT(!view->vocbase().isDangling());
|
||||||
view->vocbase()->forceUse();
|
view->vocbase().forceUse();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
auto v = new std::shared_ptr<arangodb::LogicalView>(view);
|
auto v = new std::shared_ptr<arangodb::LogicalView>(view);
|
||||||
auto externalView = v8::External::New(isolate, v);
|
auto externalView = v8::External::New(isolate, v);
|
||||||
|
@ -116,7 +117,7 @@ v8::Handle<v8::Object> WrapView(v8::Isolate* isolate,
|
||||||
v8::WeakCallbackType::kFinalizer);
|
v8::WeakCallbackType::kFinalizer);
|
||||||
v8g->increaseActiveExternals();
|
v8g->increaseActiveExternals();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
view->vocbase()->release();
|
view->vocbase().release();
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -130,7 +131,7 @@ v8::Handle<v8::Object> WrapView(v8::Isolate* isolate,
|
||||||
result->ForceSet(_IdKey,
|
result->ForceSet(_IdKey,
|
||||||
TRI_V8UInt64String<TRI_voc_cid_t>(isolate, view->id()),
|
TRI_V8UInt64String<TRI_voc_cid_t>(isolate, view->id()),
|
||||||
v8::ReadOnly);
|
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);
|
return scope.Escape<v8::Object>(result);
|
||||||
|
@ -258,7 +259,7 @@ static void JS_DropViewVocbaseObj(
|
||||||
|
|
||||||
PREVENT_EMBEDDED_TRANSACTION();
|
PREVENT_EMBEDDED_TRANSACTION();
|
||||||
|
|
||||||
auto res = view->vocbase()->dropView(*view).errorNumber();
|
auto res = view->vocbase().dropView(*view).errorNumber();
|
||||||
|
|
||||||
if (res != TRI_ERROR_NO_ERROR) {
|
if (res != TRI_ERROR_NO_ERROR) {
|
||||||
TRI_V8_THROW_EXCEPTION_MESSAGE(res, "cannot drop view");
|
TRI_V8_THROW_EXCEPTION_MESSAGE(res, "cannot drop view");
|
||||||
|
@ -479,7 +480,7 @@ static void JS_RenameViewVocbase(
|
||||||
|
|
||||||
PREVENT_EMBEDDED_TRANSACTION();
|
PREVENT_EMBEDDED_TRANSACTION();
|
||||||
|
|
||||||
int res = view->vocbase()->renameView(view, name);
|
int res = view->vocbase().renameView(view, name);
|
||||||
|
|
||||||
if (res != TRI_ERROR_NO_ERROR) {
|
if (res != TRI_ERROR_NO_ERROR) {
|
||||||
TRI_V8_THROW_EXCEPTION_MESSAGE(res, "cannot rename view");
|
TRI_V8_THROW_EXCEPTION_MESSAGE(res, "cannot rename view");
|
||||||
|
|
|
@ -1387,7 +1387,7 @@ static void MapGetVocBase(v8::Local<v8::String> const name,
|
||||||
value, WRP_VOCBASE_COL_TYPE);
|
value, WRP_VOCBASE_COL_TYPE);
|
||||||
|
|
||||||
// check if the collection is from the same database
|
// 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
|
// we cannot use collection->getStatusLocked() here, because we
|
||||||
// have no idea who is calling us (db[...]). The problem is that
|
// have no idea who is calling us (db[...]). The problem is that
|
||||||
// if we are called from within a JavaScript transaction, the
|
// if we are called from within a JavaScript transaction, the
|
||||||
|
|
|
@ -574,12 +574,15 @@ std::unordered_map<std::string, double> LogicalCollection::clusterIndexEstimates
|
||||||
if (needEstimateUpdate()){
|
if (needEstimateUpdate()){
|
||||||
readlock.unlock();
|
readlock.unlock();
|
||||||
WRITE_LOCKER(writelock, _clusterEstimatesLock);
|
WRITE_LOCKER(writelock, _clusterEstimatesLock);
|
||||||
|
|
||||||
if(needEstimateUpdate()){
|
if(needEstimateUpdate()){
|
||||||
selectivityEstimatesOnCoordinator(vocbase()->name(), name(), _clusterEstimates);
|
selectivityEstimatesOnCoordinator(vocbase().name(), name(), _clusterEstimates);
|
||||||
_clusterEstimateTTL = TRI_microtime();
|
_clusterEstimateTTL = TRI_microtime();
|
||||||
}
|
}
|
||||||
|
|
||||||
return _clusterEstimates;
|
return _clusterEstimates;
|
||||||
}
|
}
|
||||||
|
|
||||||
return _clusterEstimates;
|
return _clusterEstimates;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -704,7 +707,7 @@ Result LogicalCollection::rename(std::string&& newName, bool doSync) {
|
||||||
TRI_ASSERT(engine != nullptr);
|
TRI_ASSERT(engine != nullptr);
|
||||||
|
|
||||||
name(std::move(newName));
|
name(std::move(newName));
|
||||||
engine->changeCollection(vocbase(), id(), this, doSync);
|
engine->changeCollection(&vocbase(), id(), this, doSync);
|
||||||
} catch (basics::Exception const& ex) {
|
} catch (basics::Exception const& ex) {
|
||||||
// Engine Rename somehow failed. Reset to old name
|
// Engine Rename somehow failed. Reset to old name
|
||||||
name(std::move(oldName));
|
name(std::move(oldName));
|
||||||
|
@ -743,7 +746,7 @@ arangodb::Result LogicalCollection::drop() {
|
||||||
TRI_ASSERT(!ServerState::instance()->isCoordinator());
|
TRI_ASSERT(!ServerState::instance()->isCoordinator());
|
||||||
StorageEngine* engine = EngineSelectorFeature::ENGINE;
|
StorageEngine* engine = EngineSelectorFeature::ENGINE;
|
||||||
|
|
||||||
engine->destroyCollection(vocbase(), this);
|
engine->destroyCollection(&vocbase(), this);
|
||||||
deleted(true);
|
deleted(true);
|
||||||
_physical->drop();
|
_physical->drop();
|
||||||
|
|
||||||
|
@ -778,7 +781,7 @@ void LogicalCollection::toVelocyPackForClusterInventory(VPackBuilder& result,
|
||||||
result.add(p.value);
|
result.add(p.value);
|
||||||
}
|
}
|
||||||
if (!_distributeShardsLike.empty()) {
|
if (!_distributeShardsLike.empty()) {
|
||||||
CollectionNameResolver resolver(vocbase());
|
CollectionNameResolver resolver(&vocbase());
|
||||||
result.add("distributeShardsLike",
|
result.add("distributeShardsLike",
|
||||||
VPackValue(resolver.getCollectionNameCluster(
|
VPackValue(resolver.getCollectionNameCluster(
|
||||||
static_cast<TRI_voc_cid_t>(basics::StringUtils::uint64(
|
static_cast<TRI_voc_cid_t>(basics::StringUtils::uint64(
|
||||||
|
@ -860,7 +863,7 @@ void LogicalCollection::toVelocyPack(VPackBuilder& result, bool translateCids,
|
||||||
if (!_distributeShardsLike.empty() &&
|
if (!_distributeShardsLike.empty() &&
|
||||||
ServerState::instance()->isCoordinator()) {
|
ServerState::instance()->isCoordinator()) {
|
||||||
if (translateCids) {
|
if (translateCids) {
|
||||||
CollectionNameResolver resolver(vocbase());
|
CollectionNameResolver resolver(&vocbase());
|
||||||
result.add("distributeShardsLike",
|
result.add("distributeShardsLike",
|
||||||
VPackValue(resolver.getCollectionNameCluster(
|
VPackValue(resolver.getCollectionNameCluster(
|
||||||
static_cast<TRI_voc_cid_t>(basics::StringUtils::uint64(
|
static_cast<TRI_voc_cid_t>(basics::StringUtils::uint64(
|
||||||
|
@ -994,12 +997,12 @@ arangodb::Result LogicalCollection::updateProperties(VPackSlice const& slice,
|
||||||
if (!_isLocal) {
|
if (!_isLocal) {
|
||||||
// We need to inform the cluster as well
|
// We need to inform the cluster as well
|
||||||
return ClusterInfo::instance()->setCollectionPropertiesCoordinator(
|
return ClusterInfo::instance()->setCollectionPropertiesCoordinator(
|
||||||
vocbase()->name(), std::to_string(id()), this
|
vocbase().name(), std::to_string(id()), this
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
StorageEngine* engine = EngineSelectorFeature::ENGINE;
|
StorageEngine* engine = EngineSelectorFeature::ENGINE;
|
||||||
engine->changeCollection(vocbase(), id(), this, doSync);
|
engine->changeCollection(&vocbase(), id(), this, doSync);
|
||||||
|
|
||||||
if (DatabaseFeature::DATABASE != nullptr &&
|
if (DatabaseFeature::DATABASE != nullptr &&
|
||||||
DatabaseFeature::DATABASE->versionTracker() != nullptr) {
|
DatabaseFeature::DATABASE->versionTracker() != nullptr) {
|
||||||
|
@ -1013,12 +1016,12 @@ arangodb::Result LogicalCollection::updateProperties(VPackSlice const& slice,
|
||||||
std::shared_ptr<arangodb::velocypack::Builder> LogicalCollection::figures() const {
|
std::shared_ptr<arangodb::velocypack::Builder> LogicalCollection::figures() const {
|
||||||
if (ServerState::instance()->isCoordinator()) {
|
if (ServerState::instance()->isCoordinator()) {
|
||||||
auto builder = std::make_shared<VPackBuilder>();
|
auto builder = std::make_shared<VPackBuilder>();
|
||||||
|
|
||||||
builder->openObject();
|
builder->openObject();
|
||||||
builder->close();
|
builder->close();
|
||||||
TRI_ASSERT(vocbase());
|
|
||||||
|
|
||||||
int res =
|
int res =
|
||||||
figuresOnCoordinator(vocbase()->name(), std::to_string(id()), builder);
|
figuresOnCoordinator(vocbase().name(), std::to_string(id()), builder);
|
||||||
|
|
||||||
if (res != TRI_ERROR_NO_ERROR) {
|
if (res != TRI_ERROR_NO_ERROR) {
|
||||||
THROW_ARANGO_EXCEPTION(res);
|
THROW_ARANGO_EXCEPTION(res);
|
||||||
|
@ -1069,8 +1072,10 @@ bool LogicalCollection::dropIndex(TRI_idx_iid_t iid) {
|
||||||
#if USE_PLAN_CACHE
|
#if USE_PLAN_CACHE
|
||||||
arangodb::aql::PlanCache::instance()->invalidate(_vocbase);
|
arangodb::aql::PlanCache::instance()->invalidate(_vocbase);
|
||||||
#endif
|
#endif
|
||||||
arangodb::aql::QueryCache::instance()->invalidate(vocbase(), name());
|
arangodb::aql::QueryCache::instance()->invalidate(&vocbase(), name());
|
||||||
|
|
||||||
bool result = _physical->dropIndex(iid);
|
bool result = _physical->dropIndex(iid);
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
if (DatabaseFeature::DATABASE != nullptr &&
|
if (DatabaseFeature::DATABASE != nullptr &&
|
||||||
DatabaseFeature::DATABASE->versionTracker() != nullptr) {
|
DatabaseFeature::DATABASE->versionTracker() != nullptr) {
|
||||||
|
@ -1090,7 +1095,8 @@ void LogicalCollection::persistPhysicalCollection() {
|
||||||
// We have not yet persisted this collection!
|
// We have not yet persisted this collection!
|
||||||
TRI_ASSERT(getPhysical()->path().empty());
|
TRI_ASSERT(getPhysical()->path().empty());
|
||||||
StorageEngine* engine = EngineSelectorFeature::ENGINE;
|
StorageEngine* engine = EngineSelectorFeature::ENGINE;
|
||||||
std::string path = engine->createCollection(vocbase(), id(), this);
|
auto path = engine->createCollection(&vocbase(), id(), this);
|
||||||
|
|
||||||
getPhysical()->setPath(path);
|
getPhysical()->setPath(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1242,9 +1248,8 @@ VPackSlice LogicalCollection::keyOptions() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
ChecksumResult LogicalCollection::checksum(bool withRevisions, bool withData) 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);
|
SingleCollectionTransaction trx(ctx, id(), AccessMode::Type::READ);
|
||||||
|
|
||||||
Result res = trx.begin();
|
Result res = trx.begin();
|
||||||
|
|
||||||
if (!res.ok()) {
|
if (!res.ok()) {
|
||||||
|
|
|
@ -125,7 +125,7 @@ class LogicalDataSource {
|
||||||
uint64_t planVersion() const noexcept { return _planVersion; }
|
uint64_t planVersion() const noexcept { return _planVersion; }
|
||||||
virtual Result rename(std::string&& newName, bool doSync) = 0;
|
virtual Result rename(std::string&& newName, bool doSync) = 0;
|
||||||
Type const& type() const noexcept { return _type; }
|
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:
|
protected:
|
||||||
void deleted(bool deleted) noexcept { _deleted = deleted; }
|
void deleted(bool deleted) noexcept { _deleted = deleted; }
|
||||||
|
|
|
@ -189,7 +189,7 @@ DBServerLogicalView::~DBServerLogicalView() {
|
||||||
StorageEngine* engine = EngineSelectorFeature::ENGINE;
|
StorageEngine* engine = EngineSelectorFeature::ENGINE;
|
||||||
TRI_ASSERT(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
|
// during recovery entry is being played back from the engine
|
||||||
if (!engine->inRecovery()) {
|
if (!engine->inRecovery()) {
|
||||||
arangodb::velocypack::Builder builder;
|
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);
|
TRI_ASSERT(TRI_ERROR_NO_ERROR == res);
|
||||||
auto slice = builder.slice();
|
auto slice = builder.slice();
|
||||||
TRI_ASSERT(slice.isArray());
|
TRI_ASSERT(slice.isArray());
|
||||||
|
@ -227,9 +227,9 @@ DBServerLogicalView::~DBServerLogicalView() {
|
||||||
}
|
}
|
||||||
#endif
|
#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) {
|
} catch (std::exception const& e) {
|
||||||
return arangodb::Result(
|
return arangodb::Result(
|
||||||
TRI_ERROR_INTERNAL,
|
TRI_ERROR_INTERNAL,
|
||||||
|
@ -251,7 +251,7 @@ arangodb::Result DBServerLogicalView::drop() {
|
||||||
|
|
||||||
if (res.ok()) {
|
if (res.ok()) {
|
||||||
deleted(true);
|
deleted(true);
|
||||||
engine->dropView(vocbase(), this);
|
engine->dropView(&vocbase(), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
@ -269,7 +269,7 @@ Result DBServerLogicalView::rename(std::string&& newName, bool doSync) {
|
||||||
|
|
||||||
// store new view definition to disk
|
// store new view definition to disk
|
||||||
if (!engine->inRecovery()) {
|
if (!engine->inRecovery()) {
|
||||||
engine->changeView(vocbase(), id(), *this, doSync);
|
engine->changeView(&vocbase(), id(), *this, doSync);
|
||||||
}
|
}
|
||||||
} catch (basics::Exception const& ex) {
|
} catch (basics::Exception const& ex) {
|
||||||
name(std::move(oldName));
|
name(std::move(oldName));
|
||||||
|
@ -282,7 +282,7 @@ Result DBServerLogicalView::rename(std::string&& newName, bool doSync) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// write WAL 'rename' marker
|
// write WAL 'rename' marker
|
||||||
return engine->renameView(vocbase(), *this, oldName);
|
return engine->renameView(&vocbase(), *this, oldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DBServerLogicalView::toVelocyPack(
|
void DBServerLogicalView::toVelocyPack(
|
||||||
|
@ -310,7 +310,7 @@ void DBServerLogicalView::toVelocyPack(
|
||||||
// storage engine related properties
|
// storage engine related properties
|
||||||
StorageEngine* engine = EngineSelectorFeature::ENGINE;
|
StorageEngine* engine = EngineSelectorFeature::ENGINE;
|
||||||
TRI_ASSERT(engine);
|
TRI_ASSERT(engine);
|
||||||
engine->getViewProperties(vocbase(), this, result);
|
engine->getViewProperties(&vocbase(), this, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (includeProperties) {
|
if (includeProperties) {
|
||||||
|
@ -348,7 +348,7 @@ arangodb::Result DBServerLogicalView::updateProperties(
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
engine->changeView(vocbase(), id(), *this, doSync);
|
engine->changeView(&vocbase(), id(), *this, doSync);
|
||||||
} catch (arangodb::basics::Exception const& e) {
|
} catch (arangodb::basics::Exception const& e) {
|
||||||
return { e.code() };
|
return { e.code() };
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
|
|
|
@ -241,11 +241,9 @@ Result Collections::load(TRI_vocbase_t* vocbase, LogicalCollection* coll) {
|
||||||
TRI_ASSERT(coll != nullptr);
|
TRI_ASSERT(coll != nullptr);
|
||||||
|
|
||||||
if (ServerState::instance()->isCoordinator()) {
|
if (ServerState::instance()->isCoordinator()) {
|
||||||
TRI_ASSERT(coll->vocbase());
|
|
||||||
|
|
||||||
#ifdef USE_ENTERPRISE
|
#ifdef USE_ENTERPRISE
|
||||||
return ULColCoordinatorEnterprise(
|
return ULColCoordinatorEnterprise(
|
||||||
coll->vocbase()->name(),
|
coll->vocbase().name(),
|
||||||
std::to_string(coll->id()),
|
std::to_string(coll->id()),
|
||||||
TRI_VOC_COL_STATUS_LOADED
|
TRI_VOC_COL_STATUS_LOADED
|
||||||
);
|
);
|
||||||
|
@ -253,7 +251,7 @@ Result Collections::load(TRI_vocbase_t* vocbase, LogicalCollection* coll) {
|
||||||
auto ci = ClusterInfo::instance();
|
auto ci = ClusterInfo::instance();
|
||||||
|
|
||||||
return ci->setCollectionStatusCoordinator(
|
return ci->setCollectionStatusCoordinator(
|
||||||
coll->vocbase()->name(),
|
coll->vocbase().name(),
|
||||||
std::to_string(coll->id()),
|
std::to_string(coll->id()),
|
||||||
TRI_VOC_COL_STATUS_LOADED
|
TRI_VOC_COL_STATUS_LOADED
|
||||||
);
|
);
|
||||||
|
@ -310,7 +308,9 @@ Result Collections::properties(LogicalCollection* coll, VPackBuilder& builder) {
|
||||||
ignoreKeys.insert({"distributeShardsLike", "isSmart", "numberOfShards",
|
ignoreKeys.insert({"distributeShardsLike", "isSmart", "numberOfShards",
|
||||||
"replicationFactor", "shardKeys"});
|
"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)
|
// populate the transaction object (which is used outside this if too)
|
||||||
trx.reset(new SingleCollectionTransaction(
|
trx.reset(new SingleCollectionTransaction(
|
||||||
ctx, coll->id(), AccessMode::Type::READ
|
ctx, coll->id(), AccessMode::Type::READ
|
||||||
|
@ -352,14 +352,15 @@ Result Collections::updateProperties(LogicalCollection* coll,
|
||||||
if (ServerState::instance()->isCoordinator()) {
|
if (ServerState::instance()->isCoordinator()) {
|
||||||
ClusterInfo* ci = ClusterInfo::instance();
|
ClusterInfo* ci = ClusterInfo::instance();
|
||||||
|
|
||||||
TRI_ASSERT(coll->vocbase());
|
TRI_ASSERT(coll);
|
||||||
|
|
||||||
auto info =
|
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);
|
return info->updateProperties(props, false);
|
||||||
} else {
|
} else {
|
||||||
auto ctx = transaction::V8Context::CreateWhenRequired(coll->vocbase(), false);
|
auto ctx =
|
||||||
|
transaction::V8Context::CreateWhenRequired(&(coll->vocbase()), false);
|
||||||
SingleCollectionTransaction trx(
|
SingleCollectionTransaction trx(
|
||||||
ctx, coll->id(), AccessMode::Type::EXCLUSIVE
|
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());
|
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) {
|
if (res != TRI_ERROR_NO_ERROR) {
|
||||||
return Result(res, "cannot rename collection");
|
return Result(res, "cannot rename collection");
|
||||||
}
|
}
|
||||||
|
|
||||||
// rename collection inside _graphs as well
|
// rename collection inside _graphs as well
|
||||||
return RenameGraphCollections(coll->vocbase(), oldName, newName);
|
return RenameGraphCollections(&(coll->vocbase()), oldName, newName);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef USE_ENTERPRISE
|
#ifndef USE_ENTERPRISE
|
||||||
|
@ -455,8 +457,7 @@ static Result DropVocbaseColCoordinator(arangodb::LogicalCollection* collection,
|
||||||
return TRI_ERROR_FORBIDDEN;
|
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());
|
auto cid = std::to_string(collection->id());
|
||||||
ClusterInfo* ci = ClusterInfo::instance();
|
ClusterInfo* ci = ClusterInfo::instance();
|
||||||
std::string errorMsg;
|
std::string errorMsg;
|
||||||
|
@ -488,8 +489,8 @@ Result Collections::drop(TRI_vocbase_t* vocbase, LogicalCollection* coll,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TRI_ASSERT(coll->vocbase());
|
TRI_ASSERT(coll);
|
||||||
auto& dbname = coll->vocbase()->name();
|
auto& dbname = coll->vocbase().name();
|
||||||
std::string const collName = coll->name();
|
std::string const collName = coll->name();
|
||||||
|
|
||||||
Result res;
|
Result res;
|
||||||
|
@ -501,7 +502,8 @@ Result Collections::drop(TRI_vocbase_t* vocbase, LogicalCollection* coll,
|
||||||
res = DropVocbaseColCoordinator(coll, allowDropSystem);
|
res = DropVocbaseColCoordinator(coll, allowDropSystem);
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
int r = coll->vocbase()->dropCollection(coll, allowDropSystem, timeout);
|
int r = coll->vocbase().dropCollection(coll, allowDropSystem, timeout);
|
||||||
|
|
||||||
if (r != TRI_ERROR_NO_ERROR) {
|
if (r != TRI_ERROR_NO_ERROR) {
|
||||||
res.reset(r, "cannot drop collection");
|
res.reset(r, "cannot drop collection");
|
||||||
}
|
}
|
||||||
|
@ -558,8 +560,7 @@ Result Collections::revisionId(TRI_vocbase_t* vocbase,
|
||||||
LogicalCollection* coll,
|
LogicalCollection* coll,
|
||||||
TRI_voc_rid_t& rid) {
|
TRI_voc_rid_t& rid) {
|
||||||
TRI_ASSERT(coll != nullptr);
|
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());
|
auto cid = std::to_string(coll->id());
|
||||||
|
|
||||||
if (ServerState::instance()->isCoordinator()) {
|
if (ServerState::instance()->isCoordinator()) {
|
||||||
|
|
|
@ -101,8 +101,8 @@ arangodb::Result Indexes::getAll(LogicalCollection const* collection,
|
||||||
|
|
||||||
VPackBuilder tmp;
|
VPackBuilder tmp;
|
||||||
if (ServerState::instance()->isCoordinator()) {
|
if (ServerState::instance()->isCoordinator()) {
|
||||||
TRI_ASSERT(collection->vocbase());
|
TRI_ASSERT(collection);
|
||||||
auto& databaseName = collection->vocbase()->name();
|
auto& databaseName = collection->vocbase().name();
|
||||||
std::string const& cid = collection->name();
|
std::string const& cid = collection->name();
|
||||||
|
|
||||||
// add code for estimates here
|
// add code for estimates here
|
||||||
|
@ -141,7 +141,7 @@ arangodb::Result Indexes::getAll(LogicalCollection const* collection,
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
SingleCollectionTransaction trx(
|
SingleCollectionTransaction trx(
|
||||||
transaction::StandaloneContext::Create(collection->vocbase()),
|
transaction::StandaloneContext::Create(&(collection->vocbase())),
|
||||||
collection->id(),
|
collection->id(),
|
||||||
AccessMode::Type::READ
|
AccessMode::Type::READ
|
||||||
);
|
);
|
||||||
|
@ -248,14 +248,15 @@ static Result EnsureIndexLocal(arangodb::LogicalCollection* collection,
|
||||||
VPackSlice const& definition, bool create,
|
VPackSlice const& definition, bool create,
|
||||||
VPackBuilder& output) {
|
VPackBuilder& output) {
|
||||||
TRI_ASSERT(collection != nullptr);
|
TRI_ASSERT(collection != nullptr);
|
||||||
READ_LOCKER(readLocker, collection->vocbase()->_inventoryLock);
|
READ_LOCKER(readLocker, collection->vocbase()._inventoryLock);
|
||||||
|
|
||||||
SingleCollectionTransaction trx(
|
SingleCollectionTransaction trx(
|
||||||
transaction::V8Context::CreateWhenRequired(collection->vocbase(), false),
|
transaction::V8Context::CreateWhenRequired(&(collection->vocbase()), false),
|
||||||
collection->id(),
|
collection->id(),
|
||||||
create ? AccessMode::Type::EXCLUSIVE : AccessMode::Type::READ);
|
create ? AccessMode::Type::EXCLUSIVE : AccessMode::Type::READ
|
||||||
|
);
|
||||||
Result res = trx.begin();
|
Result res = trx.begin();
|
||||||
|
|
||||||
if (!res.ok()) {
|
if (!res.ok()) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -306,8 +307,7 @@ Result Indexes::ensureIndexCoordinator(
|
||||||
arangodb::LogicalCollection const* collection, VPackSlice const& indexDef,
|
arangodb::LogicalCollection const* collection, VPackSlice const& indexDef,
|
||||||
bool create, VPackBuilder& resultBuilder) {
|
bool create, VPackBuilder& resultBuilder) {
|
||||||
TRI_ASSERT(collection != nullptr);
|
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());
|
auto cid = std::to_string(collection->id());
|
||||||
std::string errorMsg;
|
std::string errorMsg;
|
||||||
|
|
||||||
|
@ -348,8 +348,8 @@ Result Indexes::ensureIndex(LogicalCollection* collection,
|
||||||
return Result(res);
|
return Result(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
TRI_ASSERT(collection->vocbase());
|
TRI_ASSERT(collection);
|
||||||
auto& dbname = collection->vocbase()->name();
|
auto& dbname = collection->vocbase().name();
|
||||||
std::string const collname(collection->name());
|
std::string const collname(collection->name());
|
||||||
VPackSlice indexDef = defBuilder.slice();
|
VPackSlice indexDef = defBuilder.slice();
|
||||||
|
|
||||||
|
@ -547,7 +547,7 @@ arangodb::Result Indexes::drop(LogicalCollection const* collection,
|
||||||
|
|
||||||
TRI_idx_iid_t iid = 0;
|
TRI_idx_iid_t iid = 0;
|
||||||
if (ServerState::instance()->isCoordinator()) {
|
if (ServerState::instance()->isCoordinator()) {
|
||||||
CollectionNameResolver resolver(collection->vocbase());
|
CollectionNameResolver resolver(&(collection->vocbase()));
|
||||||
Result res = Indexes::extractHandle(collection, &resolver, indexArg, iid);
|
Result res = Indexes::extractHandle(collection, &resolver, indexArg, iid);
|
||||||
if (!res.ok()) {
|
if (!res.ok()) {
|
||||||
return res;
|
return res;
|
||||||
|
@ -556,8 +556,8 @@ arangodb::Result Indexes::drop(LogicalCollection const* collection,
|
||||||
#ifdef USE_ENTERPRISE
|
#ifdef USE_ENTERPRISE
|
||||||
return Indexes::dropCoordinatorEE(collection, iid);
|
return Indexes::dropCoordinatorEE(collection, iid);
|
||||||
#else
|
#else
|
||||||
TRI_ASSERT(collection->vocbase());
|
TRI_ASSERT(collection);
|
||||||
auto& databaseName = collection->vocbase()->name();
|
auto& databaseName = collection->vocbase().name();
|
||||||
auto cid = std::to_string(collection->id());
|
auto cid = std::to_string(collection->id());
|
||||||
std::string errorMsg;
|
std::string errorMsg;
|
||||||
int r = ClusterInfo::instance()->dropIndexCoordinator(databaseName, cid,
|
int r = ClusterInfo::instance()->dropIndexCoordinator(databaseName, cid,
|
||||||
|
@ -565,10 +565,10 @@ arangodb::Result Indexes::drop(LogicalCollection const* collection,
|
||||||
return Result(r, errorMsg);
|
return Result(r, errorMsg);
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
READ_LOCKER(readLocker, collection->vocbase()->_inventoryLock);
|
READ_LOCKER(readLocker, collection->vocbase()._inventoryLock);
|
||||||
|
|
||||||
SingleCollectionTransaction trx(
|
SingleCollectionTransaction trx(
|
||||||
transaction::V8Context::CreateWhenRequired(collection->vocbase(), false),
|
transaction::V8Context::CreateWhenRequired(&(collection->vocbase()), false),
|
||||||
collection->id(),
|
collection->id(),
|
||||||
AccessMode::Type::EXCLUSIVE
|
AccessMode::Type::EXCLUSIVE
|
||||||
);
|
);
|
||||||
|
|
|
@ -428,26 +428,26 @@ bool TRI_vocbase_t::DropCollectionCallback(
|
||||||
} // release status lock
|
} // release status lock
|
||||||
|
|
||||||
// remove from list of collections
|
// remove from list of collections
|
||||||
TRI_vocbase_t* vocbase = collection->vocbase();
|
auto& vocbase = collection->vocbase();
|
||||||
|
|
||||||
{
|
{
|
||||||
RECURSIVE_WRITE_LOCKER(vocbase->_dataSourceLock, vocbase->_dataSourceLockWriteOwner);
|
RECURSIVE_WRITE_LOCKER(vocbase._dataSourceLock, vocbase._dataSourceLockWriteOwner);
|
||||||
auto it = vocbase->_collections.begin();
|
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) {
|
if (it->get() == collection) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (it != vocbase->_collections.end()) {
|
if (it != vocbase._collections.end()) {
|
||||||
auto col = *it;
|
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
|
// we need to clean up the pointers later so we insert it into this vector
|
||||||
try {
|
try {
|
||||||
vocbase->_deadCollections.emplace_back(col);
|
vocbase._deadCollections.emplace_back(col);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1284,7 +1284,7 @@ int TRI_vocbase_t::dropCollection(arangodb::LogicalCollection* collection,
|
||||||
} else {
|
} else {
|
||||||
collection->deferDropCollection(DropCollectionCallback);
|
collection->deferDropCollection(DropCollectionCallback);
|
||||||
// wake up the cleanup thread
|
// wake up the cleanup thread
|
||||||
engine->signalCleanup(collection->vocbase());
|
engine->signalCleanup(&(collection->vocbase()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DatabaseFeature::DATABASE != nullptr &&
|
if (DatabaseFeature::DATABASE != nullptr &&
|
||||||
|
|
|
@ -393,7 +393,7 @@ SECTION("test_async_index") {
|
||||||
if (!resThread0) return;
|
if (!resThread0) return;
|
||||||
|
|
||||||
arangodb::SingleCollectionTransaction trx(
|
arangodb::SingleCollectionTransaction trx(
|
||||||
arangodb::transaction::StandaloneContext::Create(collection0->vocbase()),
|
arangodb::transaction::StandaloneContext::Create(&(collection0->vocbase())),
|
||||||
collection0->id(),
|
collection0->id(),
|
||||||
arangodb::AccessMode::Type::WRITE
|
arangodb::AccessMode::Type::WRITE
|
||||||
);
|
);
|
||||||
|
@ -431,7 +431,7 @@ SECTION("test_async_index") {
|
||||||
if (!resThread1) return;
|
if (!resThread1) return;
|
||||||
|
|
||||||
arangodb::SingleCollectionTransaction trx(
|
arangodb::SingleCollectionTransaction trx(
|
||||||
arangodb::transaction::StandaloneContext::Create(collection1->vocbase()),
|
arangodb::transaction::StandaloneContext::Create(&(collection1->vocbase())),
|
||||||
collection1->id(),
|
collection1->id(),
|
||||||
arangodb::AccessMode::Type::WRITE
|
arangodb::AccessMode::Type::WRITE
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue