8000 devel: fixed the missed changes to plan after agency callback is registred f… by kvahed · Pull Request #4775 · arangodb/arangodb · GitHub
[go: up one dir, main page]

Skip to content

devel: fixed the missed changes to plan after agency callback is registred f… #4775

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
83688a6
fixed the missed changes to plan after agency callback is registred f…
kvahed Mar 7, 2018
11e3d4f
fixed the missed changes to plan after agency callback is registred f…
kvahed Mar 7, 2018
a384c28
Force check in timeout case.
neunhoef Mar 8, 2018
ac0746c
More debugging in tests.
neunhoef Mar 8, 2018
23220f0
Merge remote-tracking branch 'origin/devel' into bug-fix/create-colle…
neunhoef Mar 8, 2018
56c1769
Fail in maintainer mode with some dump in the critical case.
neunhoef Mar 8, 2018
a43814c
Merge remote-tracking branch 'origin/devel' into bug-fix/create-colle…
neunhoef Mar 9, 2018
cb5c6c3
Fix Agent behaviour. RestAgencyHandler::inquire missing.
neunhoef Mar 9, 2018
a745a5d
Merge branch 'devel' of https://github.com/arangodb/arangodb into bug…
kvahed Mar 12, 2018
c3a06a6
Sort out RestAgencyHandler behaviour for inquire.
neunhoef Mar 12, 2018
f28790f
Take "ongoing" stuff out of AgencyComm.
neunhoef Mar 12, 2018
c4ff2b4
Merge remote-tracking branch 'origin/devel' into bug-fix/create-colle…
neunhoef Mar 12, 2018
ba31cd8
Merge branch 'bug-fix/create-collection-coordinator-changes-to-plan-i…
kvahed Mar 12, 2018
d4d631c
Merge branch 'devel' of https://github.com/arangodb/arangodb into bug…
kvahed Mar 12, 2018
30741b7
merged in devel / corrected for overly talkative log level
kvahed Mar 12, 2018
198fadb
no need for loadPlan anymore
kvahed Mar 12, 2018
99d15fc
Reinstate an erroreously remove loadPlan.
neunhoef Mar 12, 2018
975ac5e
Put loadPlan back in the right place.
neunhoef Mar 12, 2018
9b68c98
need to step up the logs again
kvahed Mar 12, 2018
e925fe3
Take debugging output out again for merging.
neunhoef Mar 14, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Sort out RestAgencyHandler behaviour for inquire.
  • Loading branch information
neunhoef committed Mar 12, 2018
commit c3a06a69acb70f0a5e5eede9e17df7acbbbffdc2
15 changes: 15 additions & 0 deletions arangod/Agency/Agent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,21 @@ AgentInterface::raft_commit_t Agent::waitFor(index_t index, double timeout) {
return Agent::raft_commit_t::UNKNOWN;
}

// Check if log is committed up to index.
bool Agent::isCommitted(index_t index) {

if (size() == 1) { // single host agency
return true;
}

CONDITION_LOCKER(guard, _waitForCV);
if (leading()) {
return _commitIndex >= index;
} else {
return false;
}
}

// AgentCallback reports id of follower and its highest processed index
void Agent::reportIn(std::string const& peerId, index_t index, size_t toLog) {

Expand Down
3 changes: 3 additions & 0 deletions arangod/Agency/Agent.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ class Agent : public arangodb::Thread,
/// @brief Wait for slaves to confirm appended entries
AgentInterface::raft_commit_t waitFor(index_t last_entry, double timeout = 10.0) override;

/// @brief Check if everything up to a given index has been committed:
bool isCommitted(index_t last_entry) override;

/// @brief Convencience size of agency
size_t size() const;

Expand Down
3 changes: 3 additions & 0 deletions arangod/Agency/AgentInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ class AgentInterface {
/// @brief Wait for slaves to confirm appended entries
virtual raft_commit_t waitFor(index_t last_entry, double timeout = 2.0) = 0;

/// @brief Wait for slaves to confirm appended entries
virtual bool isCommitted(index_t last_entry) = 0;

// Suffice warnings
virtual ~AgentInterface() {};
};
Expand Down
104 changes: 48 additions & 56 deletions arangod/Agency/RestAgencyHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,9 @@ RestStatus RestAgencyHandler::handleWrite() {
body.close();

if (result == Agent::raft_commit_t::UNKNOWN) {
generateResult(rest::ResponseCode::SERVICE_UNAVAILABLE, body.slice());
generateError(rest::ResponseCode::SERVICE_UNAVAILABLE, TRI_ERROR_HTTP_SERVICE_UNAVAILABLE);
} else if (result == Agent::raft_commit_t::TIMEOUT) {
generateResult(rest::ResponseCode::REQUEST_TIMEOUT, body.slice());
generateError(rest::ResponseCode::REQUEST_TIMEOUT, 408);
} else {
if (errors > 0) { // Some/all requests failed
generateResult(rest::ResponseCode::PRECONDITION_FAILED, body.slice());
Expand Down Expand Up @@ -402,78 +402,70 @@ RestStatus RestAgencyHandler::handleInquire() {
}

if (ret.accepted) { // I am leading
#if 0
// Stuff from write: needs adapting:

bool found;
std::string call_mode = _request->header("x-ara 10000 ngodb-agency-mode", found);
if (!found) { call_mode = "waitForCommitted"; }
size_t errors = 0;
Builder body;
body.openObject();
Agent::raft_commit_t result = Agent::raft_commit_t::OK;
if (!found) {
call_mode = "waitForCommitted";
}

if (call_mode != "noWait") {
// Note success/error
body.add("results", VPackValue(VPackValueType::Array));
for (auto const& index : ret.indices) {
body.add(VPackValue(index));
if (index == 0) {
errors++;
}
}
body.close();
// First possibility: The answer is empty, we have never heard about
// these transactions. In this case we say so, regardless what the
// "agency-mode" is.
// Second possibility: Non-empty answer, but agency-mode is "noWait",
// then we simply report our findings, too.
// Third possibility, we actually have a non-empty list of indices,
// and we need to wait for commit to answer.

// Wait for commit of highest except if it is 0?
if (!ret.indices.empty() && call_mode == "waitForCommitted") {
arangodb::consensus::index_t max_index = 0;
try {
max_index =
*std::max_element(ret.indices.begin(), ret.indices.end());
} catch (std::exception const& ex) {
LOG_TOPIC(WARN, Logger::AGENCY) << ex.what();
}
// Handle cases 2 and 3:
Agent::raft_commit_t result = Agent::raft_commit_t::OK;
bool allCommitted = true;
if (!ret.indices.empty()) {
arangodb::consensus::index_t max_index = 0;
try {
max_index =
*std::max_element(ret.indices.begin(), ret.indices.end());
} catch (std::exception const& ex) {
LOG_TOPIC(WARN, Logger::AGENCY) << ex.what();
}

if (max_index > 0) {
if (max_index > 0) {
if (call_mode == "waitForCommitted") {
result = _agent->waitFor(max_index);
} else {
allCommitted = _agent->isCommitted(max_index);
}

}
}

body.close();
// We can now prepare the result:
Builder body;
bool failed = false;
{ VPackObjectBuilder b(&body);
body.add(VPackValue("results"));
{ VPackArrayBuilder bb(&body);
for (auto const& index : ret.indices) {
body.add(VPackValue(index));
failed = (failed || index == 0);
}
}
body.add("inquired", VPackValue(true));
if (!allCommitted) { // can only happen in agency_mode "noWait"
body.add("ongoing", VPackValue(true));
}
}

if (result == Agent::raft_commit_t::UNKNOWN) {
generateResult(rest::ResponseCode::SERVICE_UNAVAILABLE, body.slice());
generateError(rest::ResponseCode::SERVICE_UNAVAILABLE, TRI_ERROR_HTTP_SERVICE_UNAVAILABLE);
} else if (result == Agent::raft_commit_t::TIMEOUT) {
generateResult(rest::ResponseCode::REQUEST_TIMEOUT, body.slice());
generateError(rest::ResponseCode::REQUEST_TIMEOUT, 408);
} else {
if (errors > 0) { // Some/all requests failed
if (failed > 0) { // Some/all requests failed
generateResult(rest::ResponseCode::PRECONDITION_FAILED, body.slice());
} else { // All good
} else { // All good (or indeed unknown in case 1)
generateResult(rest::ResponseCode::OK, body.slice());
}
}
#endif

// The following is the old behaviour:
Builder body;
bool failed = false;
{ VPackObjectBuilder b(&body);
if (ret.indices.empty()) {
body.add("ongoing", VPackValue(true));
} else {
body.add(VPackValue("results"));
{ VPackArrayBuilder bb(&body);
for (auto const& index : ret.indices) {
body.add(VPackValue(index));
failed = (failed || index == 0);
}}

}
body.add("inquired", VPackValue(true));
}
generateResult(failed ? rest::ResponseCode::PRECONDITION_FAILED :
rest::ResponseCode::OK, body.slice());
} else { // Redirect to leader
if (_agent->leaderID() == NO_LEADER) {
return reportMessage(rest::ResponseCode::SERVICE_UNAVAILABLE, "No leader");
Expand Down
3 changes: 0 additions & 3 deletions arangod/Cluster/ClusterInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1356,9 +1356,6 @@ int ClusterInfo::createCollectionCoordinator(std::string const& databaseName,
}

}

// Update our cache:
loadPlan();
}

if (numberOfShards == 0) {
Expand Down
0