mirror of https://gitee.com/bigwinds/arangodb
fix memory errors and crashes
This commit is contained in:
parent
dbfbfd3a8c
commit
ebba4fd55a
|
@ -400,7 +400,7 @@ std::shared_ptr<Action> MaintenanceFeature::findReadyAction() {
|
||||||
} // MaintenanceFeature::findReadyAction
|
} // MaintenanceFeature::findReadyAction
|
||||||
|
|
||||||
|
|
||||||
VPackBuilder MaintenanceFeature::toVelocyPack() const {
|
VPackBuilder MaintenanceFeature::toVelocyPack() const {
|
||||||
VPackBuilder vb;
|
VPackBuilder vb;
|
||||||
READ_LOCKER(rLock, _actionRegistryLock);
|
READ_LOCKER(rLock, _actionRegistryLock);
|
||||||
|
|
||||||
|
|
|
@ -139,7 +139,8 @@ public:
|
||||||
bool verifyRegistryState(ExpectedVec_t & expected) {
|
bool verifyRegistryState(ExpectedVec_t & expected) {
|
||||||
bool good(true);
|
bool good(true);
|
||||||
|
|
||||||
VPackArrayIterator registry(toVelocyPack().slice());
|
VPackBuilder registryBuilder(toVelocyPack());
|
||||||
|
VPackArrayIterator registry(registryBuilder.slice());
|
||||||
|
|
||||||
auto action = registry.begin();
|
auto action = registry.begin();
|
||||||
auto check = expected.begin();
|
auto check = expected.begin();
|
||||||
|
@ -186,8 +187,10 @@ public:
|
||||||
do {
|
do {
|
||||||
again = false;
|
again = false;
|
||||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||||
VPackArrayIterator registry(toVelocyPack().slice());
|
|
||||||
for (auto action : registry ) {
|
VPackBuilder registryBuilder(toVelocyPack());
|
||||||
|
VPackArrayIterator registry(registryBuilder.slice());
|
||||||
|
for (auto action : registry) {
|
||||||
VPackSlice state = action.get("state");
|
VPackSlice state = action.get("state");
|
||||||
again = again || (COMPLETE != state.getInt() && FAILED != state.getInt());
|
again = again || (COMPLETE != state.getInt() && FAILED != state.getInt());
|
||||||
} // for
|
} // for
|
||||||
|
|
|
@ -64,7 +64,7 @@ char const* dbs2Str =
|
||||||
#include "DBServer0003.json"
|
#include "DBServer0003.json"
|
||||||
;
|
;
|
||||||
|
|
||||||
std::map<std::string,std::string> matchShortLongIds(Node const& supervision) {
|
std::map<std::string, std::string> matchShortLongIds(Node const& supervision) {
|
||||||
std::map<std::string,std::string> ret;
|
std::map<std::string,std::string> ret;
|
||||||
for (auto const& dbs : supervision("Health").children()) {
|
for (auto const& dbs : supervision("Health").children()) {
|
||||||
if (dbs.first.front() == 'P') {
|
if (dbs.first.front() == 'P') {
|
||||||
|
@ -75,7 +75,6 @@ std::map<std::string,std::string> matchShortLongIds(Node const& supervision) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Node createNodeFromBuilder(Builder const& builder) {
|
Node createNodeFromBuilder(Builder const& builder) {
|
||||||
|
|
||||||
Builder opBuilder;
|
Builder opBuilder;
|
||||||
{ VPackObjectBuilder a(&opBuilder);
|
{ VPackObjectBuilder a(&opBuilder);
|
||||||
opBuilder.add("new", builder.slice()); }
|
opBuilder.add("new", builder.slice()); }
|
||||||
|
@ -87,7 +86,6 @@ Node createNodeFromBuilder(Builder const& builder) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Builder createBuilder(char const* c) {
|
Builder createBuilder(char const* c) {
|
||||||
|
|
||||||
VPackOptions options;
|
VPackOptions options;
|
||||||
options.checkAttributeUniqueness = true;
|
options.checkAttributeUniqueness = true;
|
||||||
VPackParser parser(&options);
|
VPackParser parser(&options);
|
||||||
|
@ -108,19 +106,19 @@ std::random_device rd;
|
||||||
std::mt19937 g(rd());
|
std::mt19937 g(rd());
|
||||||
|
|
||||||
// Relevant agency
|
// Relevant agency
|
||||||
auto plan = createNode(planStr);
|
Node plan("");
|
||||||
auto originalPlan = plan;
|
Node originalPlan("");
|
||||||
auto supervision = createNode(supervisionStr);
|
Node supervision("");
|
||||||
auto current = createNode(currentStr);
|
Node current("");
|
||||||
|
|
||||||
std::vector<std::string> shortNames {
|
std::vector<std::string> const shortNames {
|
||||||
"DBServer0001","DBServer0002","DBServer0003"};
|
"DBServer0001","DBServer0002","DBServer0003"};
|
||||||
|
|
||||||
// map <shortId, UUID>
|
// map <shortId, UUID>
|
||||||
auto dbsIds = matchShortLongIds(supervision);
|
std::map<std::string,std::string> dbsIds;
|
||||||
|
|
||||||
std::string PLAN_COL_PATH = "/Collections/";
|
std::string const PLAN_COL_PATH = "/Collections/";
|
||||||
std::string PLAN_DB_PATH = "/Databases/";
|
std::string const PLAN_DB_PATH = "/Databases/";
|
||||||
|
|
||||||
size_t localId = 1016002;
|
size_t localId = 1016002;
|
||||||
|
|
||||||
|
@ -159,7 +157,6 @@ VPackBuilder createIndex(
|
||||||
}}
|
}}
|
||||||
|
|
||||||
return index;
|
return index;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void createPlanIndex(
|
void createPlanIndex(
|
||||||
|
@ -171,7 +168,6 @@ void createPlanIndex(
|
||||||
{ VPackObjectBuilder o(&val);
|
{ VPackObjectBuilder o(&val);
|
||||||
val.add("new", createIndex(type, fields, unique, sparse, deduplicate).slice()); }
|
val.add("new", createIndex(type, fields, unique, sparse, deduplicate).slice()); }
|
||||||
plan(PLAN_COL_PATH + dbname + "/" + colname + "/indexes").handle<PUSH>(val.slice());
|
plan(PLAN_COL_PATH + dbname + "/" + colname + "/indexes").handle<PUSH>(val.slice());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void createCollection(
|
void createCollection(
|
||||||
|
@ -283,6 +279,12 @@ class LogicalCollection;
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("ActionDescription", "[cluster][maintenance]") {
|
TEST_CASE("ActionDescription", "[cluster][maintenance]") {
|
||||||
|
plan = createNode(planStr);
|
||||||
|
originalPlan = plan;
|
||||||
|
supervision = createNode(supervisionStr);
|
||||||
|
current = createNode(currentStr);
|
||||||
|
|
||||||
|
dbsIds = matchShortLongIds(supervision);
|
||||||
|
|
||||||
SECTION("Construct minimal ActionDescription") {
|
SECTION("Construct minimal ActionDescription") {
|
||||||
ActionDescription desc(std::map<std::string,std::string>{{"name", "SomeAction"}});
|
ActionDescription desc(std::map<std::string,std::string>{{"name", "SomeAction"}});
|
||||||
|
@ -756,7 +758,8 @@ TEST_CASE("ActionPhaseOne", "[cluster][maintenance]") {
|
||||||
|
|
||||||
for (auto const& shard : shards) {
|
for (auto const& shard : shards) {
|
||||||
shname = shard.first;
|
shname = shard.first;
|
||||||
Slice servers = shard.second->toBuilder().slice();
|
auto shardBuilder = shard.second->toBuilder();
|
||||||
|
Slice servers = shardBuilder.slice();
|
||||||
|
|
||||||
REQUIRE(servers.isArray());
|
REQUIRE(servers.isArray());
|
||||||
REQUIRE(servers.length() == 2);
|
REQUIRE(servers.length() == 2);
|
||||||
|
|
Loading…
Reference in New Issue