Skip to content
Snippets Groups Projects
Commit a621b25d authored by Irene Zhang's avatar Irene Zhang
Browse files

fixing a bug in versioning reads in tapirstore

parent ee9edfd6
No related branches found
No related tags found
No related merge requests found
...@@ -87,7 +87,7 @@ Server::ExecConsensusUpcall(const string &str1, string &str2) ...@@ -87,7 +87,7 @@ Server::ExecConsensusUpcall(const string &str1, string &str2)
proposed); proposed);
reply.set_status(status); reply.set_status(status);
if (proposed.isValid()) { if (proposed.isValid()) {
reply.set_timestamp(proposed.getTimestamp()); proposed.serialize(reply.mutable_timestamp());
} }
reply.SerializeToString(&str2); reply.SerializeToString(&str2);
break; break;
...@@ -122,7 +122,7 @@ Server::UnloggedUpcall(const string &str1, string &str2) ...@@ -122,7 +122,7 @@ Server::UnloggedUpcall(const string &str1, string &str2)
status = store->Get(request.txnid(), request.get().key(), val); status = store->Get(request.txnid(), request.get().key(), val);
if (status == 0) { if (status == 0) {
reply.set_value(val.second); reply.set_value(val.second);
reply.set_timestamp(val.first.getTimestamp()); val.first.serialize(reply.mutable_timestamp());
} }
} }
reply.set_status(status); reply.set_status(status);
......
...@@ -177,27 +177,23 @@ ShardClient::TapirDecide(const std::set<std::string> &results) ...@@ -177,27 +177,23 @@ ShardClient::TapirDecide(const std::set<std::string> &results)
{ {
// If a majority say prepare_ok, // If a majority say prepare_ok,
int ok_count = 0; int ok_count = 0;
uint64_t ts = 0; Timestamp ts = 0;
string final_reply_str; string final_reply_str;
Reply final_reply; Reply final_reply;
for (string s : results) { for (string s : results) {
Reply reply; Reply reply;
reply.ParseFromString(s); reply.ParseFromString(s);
switch(reply.status()) { if (reply.status() == REPLY_OK) {
case REPLY_OK:
ok_count++; ok_count++;
continue; } else if (reply.status() == REPLY_FAIL) {
case REPLY_FAIL:
return s; return s;
case REPLY_RETRY: } else if (reply.status() == REPLY_RETRY) {
if (reply.timestamp() > ts) { Timestamp t(reply.timestamp());
ts = reply.timestamp(); if (t > ts) {
ts = t;
} }
continue;
default:
continue;
} }
} }
...@@ -205,6 +201,7 @@ ShardClient::TapirDecide(const std::set<std::string> &results) ...@@ -205,6 +201,7 @@ ShardClient::TapirDecide(const std::set<std::string> &results)
final_reply.set_status(REPLY_OK); final_reply.set_status(REPLY_OK);
} else { } else {
final_reply.set_status(REPLY_RETRY); final_reply.set_status(REPLY_RETRY);
ts.serialize(final_reply.mutable_timestamp());
} }
final_reply.SerializeToString(&final_reply_str); final_reply.SerializeToString(&final_reply_str);
return final_reply_str; return final_reply_str;
...@@ -303,7 +300,7 @@ ShardClient::PrepareCallback(const string &request_str, const string &reply_str) ...@@ -303,7 +300,7 @@ ShardClient::PrepareCallback(const string &request_str, const string &reply_str)
Promise *w = waiting; Promise *w = waiting;
waiting = NULL; waiting = NULL;
if (reply.has_timestamp()) { if (reply.has_timestamp()) {
w->Reply(reply.status(), Timestamp(reply.timestamp(), 0)); w->Reply(reply.status(), Timestamp(reply.timestamp()));
} else { } else {
w->Reply(reply.status(), Timestamp()); w->Reply(reply.status(), Timestamp());
} }
......
...@@ -46,7 +46,7 @@ Store::Get(uint64_t id, const string &key, pair<Timestamp,string> &value) ...@@ -46,7 +46,7 @@ Store::Get(uint64_t id, const string &key, pair<Timestamp,string> &value)
bool ret = store.get(key, value); bool ret = store.get(key, value);
if (ret) { if (ret) {
Debug("Value: %s", value.second.c_str()); Debug("Value: %s at <%lu, %lu>", value.second.c_str(), value.first.getTimestamp(), value.first.getID());
return REPLY_OK; return REPLY_OK;
} else { } else {
return REPLY_FAIL; return REPLY_FAIL;
...@@ -56,7 +56,7 @@ Store::Get(uint64_t id, const string &key, pair<Timestamp,string> &value) ...@@ -56,7 +56,7 @@ Store::Get(uint64_t id, const string &key, pair<Timestamp,string> &value)
int int
Store::Get(uint64_t id, const string &key, const Timestamp &timestamp, pair<Timestamp,string> &value) Store::Get(uint64_t id, const string &key, const Timestamp &timestamp, pair<Timestamp,string> &value)
{ {
Debug("[%lu] GET %s", id, key.c_str()); Debug("[%lu] GET %s at <%lu, %lu>", id, key.c_str(), timestamp.getTimestamp(), timestamp.getID());
bool ret = store.get(key, timestamp, value); bool ret = store.get(key, timestamp, value);
if (ret) { if (ret) {
......
...@@ -42,5 +42,5 @@ message Reply { ...@@ -42,5 +42,5 @@ message Reply {
// -3 = abstain/no reply // -3 = abstain/no reply
required int32 status = 1; required int32 status = 1;
optional string value = 2; optional string value = 2;
optional uint64 timestamp = 3; optional TimestampMessage timestamp = 3;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment