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,10 +535,12 @@ 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; }
|
||||
|
|
|
@ -23,7 +23,7 @@ const anonymize = function(doc) {
|
|||
}
|
||||
if (doc === null || typeof doc === 'number' || typeof doc === 'boolean') {
|
||||
return doc;
|
||||
}
|
||||
}
|
||||
if (typeof doc === 'object') {
|
||||
let result = {};
|
||||
Object.keys(doc).forEach(function(key) {
|
||||
|
@ -248,8 +248,8 @@ function printStats (stats) {
|
|||
stats.executionTime = stats.executionTime.toFixed(5);
|
||||
stringBuilder.appendLine(' ' + header('Writes Exec') + ' ' + header('Writes Ign') + ' ' + header('Scan Full') + ' ' +
|
||||
header('Scan Index') + ' ' + header('Filtered') + ' ' + header('Exec Time [s]'));
|
||||
|
||||
stringBuilder.appendLine(' ' + pad(1 + maxWELen - String(stats.writesExecuted).length) + value(stats.writesExecuted) + ' ' +
|
||||
|
||||
stringBuilder.appendLine(' ' + pad(1 + maxWELen - String(stats.writesExecuted).length) + value(stats.writesExecuted) + ' ' +
|
||||
pad(1 + maxWILen - String(stats.writesIgnored).length) + value(stats.writesIgnored) + ' ' +
|
||||
pad(1 + maxSFLen - String(stats.scannedFull).length) + value(stats.scannedFull) + ' ' +
|
||||
pad(1 + maxSILen - String(stats.scannedIndex).length) + value(stats.scannedIndex) + ' ' +
|
||||
|
@ -335,7 +335,7 @@ function printIndexes (indexes) {
|
|||
var ranges;
|
||||
if (indexes[i].hasOwnProperty('condition')) {
|
||||
ranges = indexes[i].condition;
|
||||
} else {
|
||||
} else {
|
||||
ranges = '[ ' + indexes[i].ranges + ' ]';
|
||||
}
|
||||
|
||||
|
@ -382,7 +382,7 @@ function printFunctions (functions) {
|
|||
maxNameLen = l;
|
||||
}
|
||||
});
|
||||
let line = ' ' +
|
||||
let line = ' ' +
|
||||
header('Name') + pad(1 + maxNameLen - 'Name'.length) + ' ' +
|
||||
header('Deterministic') + pad(1 + maxDeterministicLen - 'Deterministic'.length) + ' ' +
|
||||
header('Cacheable') + pad(1 + maxCacheableLen - 'Cacheable'.length) + ' ' +
|
||||
|
@ -974,7 +974,7 @@ function processQuery (query, explain) {
|
|||
}
|
||||
return '';
|
||||
};
|
||||
|
||||
|
||||
var iterateIndexes = function (idx, i, node, types, variable) {
|
||||
var what = (node.reverse ? 'reverse ' : '') + idx.type + ' index scan' + ((node.producesResult || !node.hasOwnProperty('producesResult')) ? (node.indexCoversProjections ? ', index only' : '') : ', scan only');
|
||||
if (types.length === 0 || what !== types[types.length - 1]) {
|
||||
|
@ -1720,8 +1720,8 @@ function debug(query, bindVars, options) {
|
|||
if (v === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
result.views[collection.name] = {
|
||||
|
||||
result.views[collection.name] = {
|
||||
type: v.type(),
|
||||
properties: v.properties()
|
||||
};
|
||||
|
@ -1730,7 +1730,7 @@ function debug(query, bindVars, options) {
|
|||
let examples;
|
||||
if (input.options.examples) {
|
||||
// include example data from collections
|
||||
let max = 10; // default number of documents
|
||||
let max = 10; // default number of documents
|
||||
if (typeof input.options.examples === 'number') {
|
||||
max = input.options.examples;
|
||||
}
|
||||
|
@ -1744,7 +1744,7 @@ function debug(query, bindVars, options) {
|
|||
examples = examples.map(anonymize);
|
||||
}
|
||||
}
|
||||
result.collections[collection.name] = {
|
||||
result.collections[collection.name] = {
|
||||
type: c.type(),
|
||||
properties: c.properties(),
|
||||
indexes: c.getIndexes(true),
|
||||
|
@ -1754,7 +1754,7 @@ function debug(query, bindVars, options) {
|
|||
};
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
result.graphs = graphs;
|
||||
return result;
|
||||
}
|
||||
|
@ -1809,7 +1809,7 @@ function inspectDump(filename, outfile) {
|
|||
print();
|
||||
});
|
||||
print();
|
||||
|
||||
|
||||
// insert example data
|
||||
print("/* example data */");
|
||||
Object.keys(data.collections).forEach(function(collection) {
|
||||
|
@ -1838,12 +1838,12 @@ function inspectDump(filename, outfile) {
|
|||
print("db._createView(" + JSON.stringify(view) + ", " + JSON.stringify(details.type) + ", " + JSON.stringify(details.properties) + ");");
|
||||
});
|
||||
print();
|
||||
|
||||
print("/* explain result */");
|
||||
|
||||
print("/* explain result */");
|
||||
print(data.fancy.trim().split(/\n/).map(function(line) { return "// " + line; }).join("\n"));
|
||||
print();
|
||||
|
||||
print("/* explain command */");
|
||||
|
||||
print("/* explain command */");
|
||||
if (data.query.options) {
|
||||
delete data.query.options.anonymize;
|
||||
delete data.query.options.colors;
|
||||
|
|
Loading…
Reference in New Issue