mirror of https://gitee.com/bigwinds/arangodb
[3.4] Updates to collection versioning. (#7260)
This commit is contained in:
parent
4362137ba4
commit
4210d9eab6
|
@ -1922,21 +1922,10 @@ void MMFilesCollection::open(bool ignoreErrors) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// successfully opened collection. now adjust version number
|
// successfully opened collection. now adjust version number
|
||||||
if (LogicalCollection::VERSION_33 != _logicalCollection.version()) {
|
if (LogicalCollection::currentVersion() != _logicalCollection.version()
|
||||||
_logicalCollection.setVersion(LogicalCollection::VERSION_33);
|
&& !engine->upgrading()) {
|
||||||
|
setCurrentVersion();
|
||||||
bool const doSync =
|
// updates have already happened elsewhere, it is safe to bump the number
|
||||||
application_features::ApplicationServer::getFeature<DatabaseFeature>(
|
|
||||||
"Database")
|
|
||||||
->forceSyncProperties();
|
|
||||||
StorageEngine* engine = EngineSelectorFeature::ENGINE;
|
|
||||||
|
|
||||||
engine->changeCollection(
|
|
||||||
_logicalCollection.vocbase(),
|
|
||||||
_logicalCollection.id(),
|
|
||||||
_logicalCollection,
|
|
||||||
doSync
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3140,6 +3129,13 @@ void MMFilesCollection::removeLocalDocumentId(LocalDocumentId const& documentId,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MMFilesCollection::hasAllPersistentLocalIds() const {
|
||||||
|
TRI_ASSERT(_hasAllPersistentLocalIds.load() !=
|
||||||
|
(_logicalCollection.version() <
|
||||||
|
LogicalCollection::CollectionVersions::VERSION_34));
|
||||||
|
return _hasAllPersistentLocalIds.load();
|
||||||
|
}
|
||||||
|
|
||||||
Result MMFilesCollection::persistLocalDocumentIdsForDatafile(
|
Result MMFilesCollection::persistLocalDocumentIdsForDatafile(
|
||||||
MMFilesCollection& collection, MMFilesDatafile& file) {
|
MMFilesCollection& collection, MMFilesDatafile& file) {
|
||||||
Result res;
|
Result res;
|
||||||
|
@ -3185,6 +3181,12 @@ Result MMFilesCollection::persistLocalDocumentIdsForDatafile(
|
||||||
}
|
}
|
||||||
|
|
||||||
Result MMFilesCollection::persistLocalDocumentIds() {
|
Result MMFilesCollection::persistLocalDocumentIds() {
|
||||||
|
if (_logicalCollection.version() >=
|
||||||
|
LogicalCollection::CollectionVersions::VERSION_34) {
|
||||||
|
// already good, just continue
|
||||||
|
return Result();
|
||||||
|
}
|
||||||
|
|
||||||
WRITE_LOCKER(dataLocker, _dataLock);
|
WRITE_LOCKER(dataLocker, _dataLock);
|
||||||
TRI_ASSERT(_compactors.empty());
|
TRI_ASSERT(_compactors.empty());
|
||||||
|
|
||||||
|
@ -3210,9 +3212,27 @@ Result MMFilesCollection::persistLocalDocumentIds() {
|
||||||
TRI_ASSERT(_compactors.empty());
|
TRI_ASSERT(_compactors.empty());
|
||||||
TRI_ASSERT(_journals.empty());
|
TRI_ASSERT(_journals.empty());
|
||||||
|
|
||||||
|
// mark collection as upgraded so we can avoid re-checking
|
||||||
|
setCurrentVersion();
|
||||||
|
|
||||||
return Result();
|
return Result();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MMFilesCollection::setCurrentVersion() {
|
||||||
|
_logicalCollection.setVersion(
|
||||||
|
static_cast<LogicalCollection::CollectionVersions>(
|
||||||
|
LogicalCollection::currentVersion()));
|
||||||
|
|
||||||
|
bool const doSync =
|
||||||
|
application_features::ApplicationServer::getFeature<DatabaseFeature>(
|
||||||
|
"Database")
|
||||||
|
->forceSyncProperties();
|
||||||
|
StorageEngine* engine = EngineSelectorFeature::ENGINE;
|
||||||
|
|
||||||
|
engine->changeCollection(_logicalCollection.vocbase(),
|
||||||
|
_logicalCollection.id(), _logicalCollection, doSync);
|
||||||
|
}
|
||||||
|
|
||||||
/// @brief creates a new entry in the primary index
|
/// @brief creates a new entry in the primary index
|
||||||
Result MMFilesCollection::insertPrimaryIndex(transaction::Methods* trx,
|
Result MMFilesCollection::insertPrimaryIndex(transaction::Methods* trx,
|
||||||
LocalDocumentId const& documentId,
|
LocalDocumentId const& documentId,
|
||||||
|
|
|
@ -535,11 +535,13 @@ class MMFilesCollection final : public PhysicalCollection {
|
||||||
|
|
||||||
LocalDocumentId reuseOrCreateLocalDocumentId(OperationOptions const& options) const;
|
LocalDocumentId reuseOrCreateLocalDocumentId(OperationOptions const& options) const;
|
||||||
|
|
||||||
bool hasAllPersistentLocalIds() const { return _hasAllPersistentLocalIds.load(); }
|
bool hasAllPersistentLocalIds() const;
|
||||||
|
|
||||||
static Result persistLocalDocumentIdsForDatafile(
|
static Result persistLocalDocumentIdsForDatafile(
|
||||||
MMFilesCollection& collection, MMFilesDatafile& file);
|
MMFilesCollection& collection, MMFilesDatafile& file);
|
||||||
|
|
||||||
|
void setCurrentVersion();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
mutable arangodb::MMFilesDitches _ditches;
|
mutable arangodb::MMFilesDitches _ditches;
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,12 @@ class LogicalCollection : public LogicalDataSource {
|
||||||
LogicalCollection& operator=(LogicalCollection const&) = delete;
|
LogicalCollection& operator=(LogicalCollection const&) = delete;
|
||||||
virtual ~LogicalCollection();
|
virtual ~LogicalCollection();
|
||||||
|
|
||||||
enum CollectionVersions { VERSION_30 = 5, VERSION_31 = 6, VERSION_33 = 7 };
|
enum CollectionVersions {
|
||||||
|
VERSION_30 = 5,
|
||||||
|
VERSION_31 = 6,
|
||||||
|
VERSION_33 = 7,
|
||||||
|
VERSION_34 = 8
|
||||||
|
};
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief the category representing a logical collection
|
/// @brief the category representing a logical collection
|
||||||
|
@ -99,7 +104,7 @@ class LogicalCollection : public LogicalDataSource {
|
||||||
/// @brief hard-coded minimum version number for collections
|
/// @brief hard-coded minimum version number for collections
|
||||||
static constexpr uint32_t minimumVersion() { return VERSION_30; }
|
static constexpr uint32_t minimumVersion() { return VERSION_30; }
|
||||||
/// @brief current version for collections
|
/// @brief current version for collections
|
||||||
static constexpr uint32_t currentVersion() { return VERSION_33; }
|
static constexpr uint32_t currentVersion() { return VERSION_34; }
|
||||||
|
|
||||||
// SECTION: Meta Information
|
// SECTION: Meta Information
|
||||||
uint32_t version() const { return _version; }
|
uint32_t version() const { return _version; }
|
||||||
|
|
Loading…
Reference in New Issue