summaryrefslogtreecommitdiffstats
path: root/documentapi
diff options
context:
space:
mode:
authorTor Brede Vekterli <vekterli@yahoo-inc.com>2016-11-16 12:02:25 +0100
committerGitHub <noreply@github.com>2016-11-16 12:02:25 +0100
commita589b650c81a9d8e2f0bf9a29195e6c160f455c8 (patch)
tree4c41a85843683d52595838f74af8d538a29dac0f /documentapi
parent1c56eec1f6daf95f8e6b165fcfb15064a28f3a8d (diff)
Implement distributor bucket ownership handover safe time point (#1098)
This adds a period of time after each distributor bucket ownership handover edge where mutations requiring timestamp assignments are bounced back to the client. This is in order to avoid the possibility of generating the same timestamp as a previous distributor whose bucket subset we now own. The time period is configurable in whole seconds based on expected worst-case cluster clock skew and the feature may be disabled entirely by setting the configured value to zero. Read-only operations and mutating operations that don't require new timestamps (such as RemoveLocation are allowed through).
Diffstat (limited to 'documentapi')
-rw-r--r--documentapi/src/tests/messages/error_codes_test.cpp22
-rw-r--r--documentapi/src/vespa/documentapi/messagebus/documentprotocol.cpp2
2 files changed, 24 insertions, 0 deletions
diff --git a/documentapi/src/tests/messages/error_codes_test.cpp b/documentapi/src/tests/messages/error_codes_test.cpp
index 57c97956d0d..7f158b9f451 100644
--- a/documentapi/src/tests/messages/error_codes_test.cpp
+++ b/documentapi/src/tests/messages/error_codes_test.cpp
@@ -14,7 +14,10 @@ using NamedErrorCodes = std::map<std::string, uint32_t>;
// DocumentAPI C++ module uses Ye Olde Test Framework.
class ErrorCodesTest : public vespalib::TestApp {
int Main() override;
+
void error_codes_match_java_definitions();
+ void stringification_is_defined_for_all_error_codes();
+
NamedErrorCodes all_document_protocol_error_codes();
std::string path_prefixed(const std::string& file_name) const;
};
@@ -115,12 +118,31 @@ ErrorCodesTest::error_codes_match_java_definitions()
EXPECT_EQUAL(cpp_golden_data, java_golden_data);
}
+void
+ErrorCodesTest::stringification_is_defined_for_all_error_codes()
+{
+ using documentapi::DocumentProtocol;
+ NamedErrorCodes codes(all_document_protocol_error_codes());
+ for (auto& kv : codes) {
+ // Ugh, special casing due to divergence between Java and C++ naming.
+ // Can we fix this without breaking anything in exciting ways?
+ if (kv.second != DocumentProtocol::ERROR_EXISTS) {
+ EXPECT_EQUAL(kv.first, "ERROR_" +
+ DocumentProtocol::getErrorName(kv.second));
+ } else {
+ EXPECT_EQUAL("EXISTS", DocumentProtocol::getErrorName(kv.second));
+ }
+ }
+}
+
int
ErrorCodesTest::Main()
{
TEST_INIT("error_codes_test");
error_codes_match_java_definitions();
TEST_FLUSH();
+ stringification_is_defined_for_all_error_codes();
+ TEST_FLUSH();
TEST_DONE();
}
diff --git a/documentapi/src/vespa/documentapi/messagebus/documentprotocol.cpp b/documentapi/src/vespa/documentapi/messagebus/documentprotocol.cpp
index 127235211d6..59dc90343b8 100644
--- a/documentapi/src/vespa/documentapi/messagebus/documentprotocol.cpp
+++ b/documentapi/src/vespa/documentapi/messagebus/documentprotocol.cpp
@@ -181,6 +181,7 @@ string
DocumentProtocol::getErrorName(uint32_t errorCode) {
switch (errorCode) {
case ERROR_MESSAGE_IGNORED: return "MESSAGE_IGNORED";
+ case ERROR_POLICY_FAILURE: return "POLICY_FAILURE";
case ERROR_DOCUMENT_NOT_FOUND: return "DOCUMENT_NOT_FOUND";
case ERROR_EXISTS: return "EXISTS";
case ERROR_BUCKET_NOT_FOUND: return "BUCKET_NOT_FOUND";
@@ -194,6 +195,7 @@ DocumentProtocol::getErrorName(uint32_t errorCode) {
case ERROR_INTERNAL_FAILURE: return "INTERNAL_FAILURE";
case ERROR_PROCESSING_FAILURE: return "PROCESSING_FAILURE";
case ERROR_TIMESTAMP_EXIST: return "TIMESTAMP_EXIST";
+ case ERROR_STALE_TIMESTAMP: return "STALE_TIMESTAMP";
case ERROR_NODE_NOT_READY: return "NODE_NOT_READY";
case ERROR_WRONG_DISTRIBUTION: return "WRONG_DISTRIBUTION";
case ERROR_REJECTED: return "REJECTED";