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
|
||||
if (LogicalCollection::VERSION_33 != _logicalCollection.version()) {
|
||||
_logicalCollection.setVersion(LogicalCollection::VERSION_33);
|
||||
|
||||
bool const doSync =
|
||||
application_features::ApplicationServer::getFeature<DatabaseFeature>(
|
||||
"Database")
|
||||
->forceSyncProperties();
|
||||
StorageEngine* engine = EngineSelectorFeature::ENGINE;
|
||||
|
||||
engine->changeCollection(
|
||||
_logicalCollection.vocbase(),
|
||||
_logicalCollection.id(),
|
||||
_logicalCollection,
|
||||
doSync
|
||||
);
|
||||
if (LogicalCollection::currentVersion() != _logicalCollection.version()
|
||||
&& !engine->upgrading()) {
|
||||
setCurrentVersion();
|
||||
// updates have already happened elsewhere, it is safe to bump the number
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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(
|
||||
MMFilesCollection& collection, MMFilesDatafile& file) {
|
||||
Result res;
|
||||
|
@ -3185,6 +3181,12 @@ Result MMFilesCollection::persistLocalDocumentIdsForDatafile(
|
|||
}
|
||||
|
||||
Result MMFilesCollection::persistLocalDocumentIds() {
|
||||
if (_logicalCollection.version() >=
|
||||
LogicalCollection::CollectionVersions::VERSION_34) {
|
||||
// already good, just continue
|
||||
return Result();
|
||||
}
|
||||
|
||||
WRITE_LOCKER(dataLocker, _dataLock);
|
||||
TRI_ASSERT(_compactors.empty());
|
||||
|
||||
|
@ -3210,9 +3212,27 @@ Result MMFilesCollection::persistLocalDocumentIds() {
|
|||
TRI_ASSERT(_compactors.empty());
|
||||
TRI_ASSERT(_journals.empty());
|
||||
|
||||
// mark collection as upgraded so we can avoid re-checking
|
||||
setCurrentVersion();
|
||||
|
||||
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
|
||||
Result MMFilesCollection::insertPrimaryIndex(transaction::Methods* trx,
|
||||
LocalDocumentId const& documentId,
|
||||
|
|
|
@ -535,11 +535,13 @@ class MMFilesCollection final : public PhysicalCollection {
|
|||
|
||||
LocalDocumentId reuseOrCreateLocalDocumentId(OperationOptions const& options) const;
|
||||
|
||||
bool hasAllPersistentLocalIds() const { return _hasAllPersistentLocalIds.load(); }
|
||||
bool hasAllPersistentLocalIds() const;
|
||||
|
||||
static Result persistLocalDocumentIdsForDatafile(
|
||||
MMFilesCollection& collection, MMFilesDatafile& file);
|
||||
|
||||
void setCurrentVersion();
|
||||
|
||||
private:
|
||||
mutable arangodb::MMFilesDitches _ditches;
|
||||
|
||||
|
|
|
@ -89,7 +89,12 @@ class LogicalCollection : public LogicalDataSource {
|
|||
LogicalCollection& operator=(LogicalCollection const&) = delete;
|
||||
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
|
||||
|
@ -99,7 +104,7 @@ class LogicalCollection : public LogicalDataSource {
|
|||
/// @brief hard-coded minimum version number for collections
|
||||
static constexpr uint32_t minimumVersion() { return VERSION_30; }
|
||||
/// @brief current version for collections
|
||||
static constexpr uint32_t currentVersion() { return VERSION_33; }
|
||||
static constexpr uint32_t currentVersion() { return VERSION_34; }
|
||||
|
||||
// SECTION: Meta Information
|
||||
uint32_t version() const { return _version; }
|
||||
|
|
Loading…
Reference in New Issue