KUDU-1770 [c++ client] propagate timestamp for write operations Updated the Kudu C++ client library to propagate timestamp for write operations.
This is a fix for KUDU-1770 C++ client: propagate timestamp for write operations This patch also enables the integration test which was failing prior to this fix: ConsistencyITest.TestTimestampPropagationForWriteOps Change-Id: I17feb6b2dacd0ba7c8b57464f1a50de99de2f772 Reviewed-on: http://gerrit.cloudera.org:8080/5269 Reviewed-by: David Ribeiro Alves <[email protected]> Tested-by: Kudu Jenkins Project: http://git-wip-us.apache.org/repos/asf/kudu/repo Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/e4f7e926 Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/e4f7e926 Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/e4f7e926 Branch: refs/heads/master Commit: e4f7e926c4205ffec04b651afc178bd0b447a9ae Parents: eb1f454 Author: Alexey Serbin <[email protected]> Authored: Tue Nov 29 14:58:31 2016 -0800 Committer: David Ribeiro Alves <[email protected]> Committed: Wed Nov 30 22:53:27 2016 +0000 ---------------------------------------------------------------------- src/kudu/client/batcher.cc | 13 ++++++++++--- src/kudu/integration-tests/consistency-itest.cc | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/kudu/blob/e4f7e926/src/kudu/client/batcher.cc ---------------------------------------------------------------------- diff --git a/src/kudu/client/batcher.cc b/src/kudu/client/batcher.cc index 61ff087..b1e9159 100644 --- a/src/kudu/client/batcher.cc +++ b/src/kudu/client/batcher.cc @@ -194,7 +194,8 @@ class WriteRpc : public RetriableRpc<RemoteTabletServer, WriteRequestPB, WriteRe vector<InFlightOp*> ops, const MonoTime& deadline, const shared_ptr<Messenger>& messenger, - const string& tablet_id); + const string& tablet_id, + uint64_t propagated_timestamp); virtual ~WriteRpc(); string ToString() const override; @@ -231,7 +232,8 @@ WriteRpc::WriteRpc(const scoped_refptr<Batcher>& batcher, vector<InFlightOp*> ops, const MonoTime& deadline, const shared_ptr<Messenger>& messenger, - const string& tablet_id) + const string& tablet_id, + uint64_t propagated_timestamp) : RetriableRpc(replica_picker, request_tracker, deadline, messenger), batcher_(batcher), ops_(std::move(ops)), @@ -250,6 +252,10 @@ WriteRpc::WriteRpc(const scoped_refptr<Batcher>& batcher, LOG(FATAL) << "Unsupported consistency mode: " << batcher->external_consistency_mode(); } + // If set, propagate the latest observed timestamp. + if (PREDICT_TRUE(propagated_timestamp != KuduClient::kNoTimestamp)) { + req_.set_propagated_timestamp(propagated_timestamp); + } // Set up schema CHECK_OK(SchemaToPB(*schema, req_.mutable_schema(), @@ -695,7 +701,8 @@ void Batcher::FlushBuffer(RemoteTablet* tablet, const vector<InFlightOp*>& ops) ops, deadline_, client_->data_->messenger_, - tablet->tablet_id()); + tablet->tablet_id(), + client_->data_->GetLatestObservedTimestamp()); rpc->SendRpc(); } http://git-wip-us.apache.org/repos/asf/kudu/blob/e4f7e926/src/kudu/integration-tests/consistency-itest.cc ---------------------------------------------------------------------- diff --git a/src/kudu/integration-tests/consistency-itest.cc b/src/kudu/integration-tests/consistency-itest.cc index 2d763c4..10c0574 100644 --- a/src/kudu/integration-tests/consistency-itest.cc +++ b/src/kudu/integration-tests/consistency-itest.cc @@ -382,7 +382,7 @@ TEST_F(ConsistencyITest, TestTimestampPropagationFromScans) { // write operation. Since a write operation should always advance the server // clock, the resulting timestamp returned to the client should be strictly // greater than the propagated one. -TEST_F(ConsistencyITest, DISABLED_TestTimestampPropagationForWriteOps) { +TEST_F(ConsistencyITest, TestTimestampPropagationForWriteOps) { const int32_t offset_usec = FLAGS_max_clock_sync_error_usec; // Assuming the offset is specified as a positive number. ASSERT_GT(offset_usec, 0);
