1
0
Fork 0

Bug fix 3.3/fixes 1805 (#5392)

This commit is contained in:
Jan 2018-05-18 18:10:52 +02:00 committed by GitHub
parent 8b8476c77e
commit 0740cb91e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 104 additions and 23 deletions

View File

@ -853,14 +853,13 @@ void Index::warmup(arangodb::transaction::Methods*,
}
std::pair<bool, double> Index::updateClusterEstimate(double defaultValue) {
// try to receive an selectivity estimate for the index
// try to receive a selectivity estimate for the index
// from indexEstimates stored in the logical collection.
// the caller has to guarantee that the _collection is valid.
// on the coordinator _collection is not always vaild!
std::pair<bool, double> rv(false, defaultValue);
auto estimates = _collection->clusterIndexEstimates();
auto estimates = _collection->clusterIndexEstimates(true);
auto found = estimates.find(std::to_string(_iid));
if ( found != estimates.end()) {
@ -869,7 +868,7 @@ std::pair<bool,double> Index::updateClusterEstimate(double defaultValue) {
_clusterSelectivity = rv.second;
}
return rv;
};
}
/// @brief append the index description to an output stream
std::ostream& operator<<(std::ostream& stream, arangodb::Index const* index) {

View File

@ -388,7 +388,6 @@ void RocksDBCollection::prepareIndexes(
}
}
#ifdef ARANGODB_ENABLE_MAINTAINER_MODE
if (_indexes[0]->type() != Index::IndexType::TRI_IDX_TYPE_PRIMARY_INDEX ||
(_logicalCollection->type() == TRI_COL_TYPE_EDGE &&
(_indexes[1]->type() != Index::IndexType::TRI_IDX_TYPE_EDGE_INDEX ||
@ -396,11 +395,13 @@ void RocksDBCollection::prepareIndexes(
LOG_TOPIC(ERR, arangodb::Logger::FIXME)
<< "got invalid indexes for collection '" << _logicalCollection->name()
<< "'";
#ifdef ARANGODB_ENABLE_MAINTAINER_MODE
for (auto it : _indexes) {
LOG_TOPIC(ERR, arangodb::Logger::FIXME) << "- " << it.get();
}
LOG_TOPIC(ERR, arangodb::Logger::FIXME) << "- " << it->context();
}
#endif
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_BAD_PARAMETER, std::string("got invalid indexes for collection '") + _logicalCollection->name() + "'");
}
}
static std::shared_ptr<Index> findIndex(

View File

@ -2932,7 +2932,7 @@ transaction::Methods::indexesForCollectionCoordinator(
std::shared_ptr<LogicalCollection> collection = clusterInfo->getCollection(databaseName(), name);
std::vector<std::shared_ptr<Index>> indexes = collection->getIndexes();
collection->clusterIndexEstimates(); // update estiamtes in logical collection
collection->clusterIndexEstimates(); // update estimates in logical collection
// push updated values into indexes
for (auto i : indexes) {
i->updateClusterEstimate();

View File

@ -630,10 +630,10 @@ std::unordered_map<std::string, double> LogicalCollection::clusterIndexEstimates
return _clusterEstimates;
}
double ctime = TRI_microtime(); // in seconds
double const ctime = TRI_microtime(); // in seconds
auto needEstimateUpdate = [this,ctime]() {
if (_clusterEstimates.empty()) {
LOG_TOPIC(TRACE, Logger::CLUSTER) << "update because estimate is not availabe";
LOG_TOPIC(TRACE, Logger::CLUSTER) << "update because estimate is not available";
return true;
} else if (ctime - _clusterEstimateTTL > 60.0) {
LOG_TOPIC(TRACE, Logger::CLUSTER) << "update because estimate is too old: " << ctime - _clusterEstimateTTL;

View File

@ -199,7 +199,7 @@ class LogicalCollection {
std::unordered_map<std::string, double> clusterIndexEstimates(bool doNotUpdate = false);
void clusterIndexEstimates(std::unordered_map<std::string, double>&& estimates);
double clusterIndexEstimatesTTL(){
double clusterIndexEstimatesTTL() const {
return _clusterEstimateTTL;
}

View File

@ -0,0 +1,81 @@
/*jshint globalstrict:false, strict:false */
/*global assertEqual, assertNull, fail */
////////////////////////////////////////////////////////////////////////////////
/// @brief test the collection interface
///
/// @file
///
/// DISCLAIMER
///
/// Copyright 2010-2012 triagens GmbH, Cologne, Germany
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
/// Copyright holder is triAGENS GmbH, Cologne, Germany
///
/// @author Dr. Frank Celler
/// @author Copyright 2012, triAGENS GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////
var jsunity = require("jsunity");
var arangodb = require("@arangodb");
var internal = require("internal");
var ArangoCollection = arangodb.ArangoCollection;
var db = arangodb.db;
var ERRORS = arangodb.errors;
function CollectionSuite() {
let cn = "example";
return {
setUp: function() {
db._drop(cn);
},
tearDown: function() {
db._drop(cn);
},
testCreateWithInvalidIndexes1 : function () {
try {
db._create(cn, { indexes: [{ id: "1", type: "edge", fields: ["_from"] }] });
fail();
} catch (err) {
assertEqual(ERRORS.ERROR_BAD_PARAMETER.code, err.errorNum);
}
assertNull(db._collection(cn));
},
testCreateWithInvalidIndexes2 : function () {
let cn = "example";
db._drop(cn);
try {
db._create(cn, { indexes: [{ id: "1234", type: "hash", fields: ["a"] }] });
fail();
} catch (err) {
assertEqual(ERRORS.ERROR_BAD_PARAMETER.code, err.errorNum);
}
assertNull(db._collection(cn));
}
};
}
jsunity.run(CollectionSuite);
return jsunity.done();