8000 Merge branch 'engine-api' of https://github.com/arangodb/arangodb int… · georgekaf/arangodb@fd6eba7 · GitHub
[go: up one dir, main page]

Skip to content

Commit fd6eba7

Browse files
committed
Merge branch 'engine-api' of https://github.com/arangodb/arangodb into engine-api
2 parents c2d7412 + 9b69035 commit fd6eba7

File tree

5 files changed

+32
-24
lines changed

5 files changed

+32
-24
lines changed

arangod/Cluster/ClusterInfo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ void ClusterInfo::loadPlan() {
466466
std::shared_ptr<LogicalCollection> newCollection;
467467
#ifndef USE_ENTERPRISE
468468
newCollection = std::make_shared<LogicalCollection>(
469-
vocbase, collectionSlice, false);
469+
vocbase, collectionSlice);
470470
#else
471471
VPackSlice isSmart = collectionSlice.get("isSmart");
472472
if (isSmart.isTrue()) {
@@ -480,7 +480,7 @@ void ClusterInfo::loadPlan() {
480480
}
481481
} else {
482482
newCollection = std::make_shared<LogicalCollection>(
483-
vocbase, collectionSlice, false);
483+
vocbase, collectionSlice);
484484
}
485485
#endif
486486
std::string const collectionName = newCollection->name();

arangod/MMFiles/MMFilesEngine.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1282,7 +1282,7 @@ TRI_vocbase_t* MMFilesEngine::openExistingDatabase(TRI_voc_tick_t id, std::strin
12821282
for (auto const& it : VPackArrayIterator(slice)) {
12831283
// we found a collection that is still active
12841284
TRI_ASSERT(!it.get("id").isNone() || !it.get("cid").isNone());
1285-
auto uniqCol = std::make_unique<arangodb::LogicalCollection>(vocbase.get(), it, true);
1285+
auto uniqCol = std::make_unique<arangodb::LogicalCollection>(vocbase.get(), it);
12861286
auto collection = uniqCol.get();
12871287
TRI_ASSERT(collection != nullptr);
12881288
StorageEngine::registerCollection(vocbase.get(), uniqCol.get());

arangod/VocBase/LogicalCollection.cpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ LogicalCollection::LogicalCollection(LogicalCollection const& other)
168168
_cleanupIndexes(0),
169169
_persistentIndexes(0),
170170
_physical(other.getPhysical()->clone(this, other.getPhysical())) {
171+
TRI_ASSERT(_physical != nullptr);
171172
if (ServerState::instance()->isDBServer() ||
172173
!ServerState::instance()->isRunningInCluster()) {
173174
_followers.reset(new FollowerInfo(this));
@@ -185,7 +186,7 @@ LogicalCollection::LogicalCollection(LogicalCollection const& other)
185186
// The Slice contains the part of the plan that
186187
// is relevant for this collection.
187188
LogicalCollection::LogicalCollection(TRI_vocbase_t* vocbase,
188-
VPackSlice const& info, bool isPhysical)
189+
VPackSlice const& info)
189190
: _internalVersion(0),
190191
_cid(ReadCid(info)),
191192
_planId(ReadPlanId(info, _cid)),
@@ -215,7 +216,7 @@ LogicalCollection::LogicalCollection(TRI_vocbase_t* vocbase,
215216
_persistentIndexes(0),
216217
_physical(
217218
EngineSelectorFeature::ENGINE->createPhysicalCollection(this, info)) {
218-
getPhysical()->setPath(ReadStringValue(info, "path", ""));
219+
TRI_ASSERT(_physical != nullptr);
219220
if (!IsAllowedName(info)) {
220221
THROW_ARANGO_EXCEPTION(TRI_ERROR_ARANGO_ILLEGAL_NAME);
221222
}
@@ -398,29 +399,13 @@ LogicalCollection::LogicalCollection(TRI_vocbase_t* vocbase,
398399
}
399400
#endif
400401

401-
if (!ServerState::instance()->isCoordinator() && isPhysical) {
402-
// If we are not in the coordinator we need a path
403-
// to the physical data.
404-
StorageEngine* engine = EngineSelectorFeature::ENGINE;
405-
if (getPhysical()->path().empty()) {
406-
std::string path = engine->createCollection(_vocbase, _cid, this);
407-
getPhysical()->setPath(path);
408-
}
409-
}
410-
411-
int64_t count = Helper::readNumericValue<int64_t>(info, "count", -1);
412-
if (count != -1) {
413-
_physical->updateCount(count);
414-
}
415-
416402
if (ServerState::instance()->isDBServer() ||
417403
!ServerState::instance()->isRunningInCluster()) {
418404
_followers.reset(new FollowerInfo(this));
419405
}
420406

421407
// update server's tick value
422408
TRI_UpdateTickServer(static_cast<TRI_voc_tick_t>(_cid));
423-
424409
}
425410

426411
LogicalCollection::~LogicalCollection() {}
@@ -1128,6 +1113,21 @@ bool LogicalCollection::dropIndex(TRI_idx_iid_t iid) {
11281113
return _physical->dropIndex(iid);
11291114
}
11301115

1116+
1117+
/// @brief Persist the connected physical collection.
1118+
/// This should be called AFTER the collection is successfully
1119+
/// created and only on Sinlge/DBServer
1120+
void LogicalCollection::persistPhysicalCollection() {
1121+
// Coordinators are not allowed to have local collections!
1122+
TRI_ASSERT(!ServerState::instance()->isCoordinator());
1123+
1124+
// We have not yet persisted this collection!
1125+
TRI_ASSERT(getPhysical()->path().empty());
1126+
StorageEngine* engine = EngineSelectorFeature::ENGINE;
1127+
std::string path = engine->createCollection(_vocbase, _cid, this);
1128+
getPhysical()->setPath(path);
1129+
}
1130+
11311131
/// @brief creates the initial indexes for the collection
11321132
void LogicalCollection::createInitialIndexes() {
11331133
if (!_indexes.empty()) {

arangod/VocBase/LogicalCollection.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@ class LogicalCollection {
9292
friend struct ::TRI_vocbase_t;
9393

9494
public:
95-
LogicalCollection(TRI_vocbase_t*, velocypack::Slice const&,
96-
bool isPhysical);
95+
LogicalCollection(TRI_vocbase_t*, velocypack::Slice const&);
9796

9897
virtual ~LogicalCollection();
9998

@@ -318,6 +317,11 @@ class LogicalCollection {
318317
TRI_voc_tick_t maxTick,
319318
ManagedDocumentResult& result);
320319

320+
/// @brief Persist the connected physical collection.
321+
/// This should be called AFTER the collection is successfully
322+
/// created and only on Sinlge/DBServer
323+
void persistPhysicalCollection();
324+
321325
private:
322326
// SECTION: Index creation
323327

arangod/VocBase/vocbase.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ arangodb::LogicalCollection* TRI_vocbase_t::createCollectionWorker(
339339
// Try to create a new collection. This is not registered yet
340340

341341
std::unique_ptr<arangodb::LogicalCollection> collection =
342-
std::make_unique<arangodb::LogicalCollection>(this, parameters, true);
342+
std::make_unique<arangodb::LogicalCollection>(this, parameters);
343343
TRI_ASSERT(collection != nullptr);
344344

345345
WRITE_LOCKER(writeLocker, _collectionsLock);
@@ -364,6 +364,10 @@ arangodb::LogicalCollection* TRI_vocbase_t::createCollectionWorker(
364364
collection->setStatus(TRI_VOC_COL_STATUS_LOADED);
365365
// set collection version to 3.1, as the collection is just created
366366
collection->setVersion(LogicalCollection::VERSION_31);
367+
368+
// Let's try to persist it.
369+
collection->persistPhysicalCollection();
370+
367371
events::CreateCollection(name, TRI_ERROR_NO_ERROR);
368372
return collection.release();
369373
} catch (...) {

0 commit comments

Comments
 (0)
0