Skip to content

Commit

Permalink
ENG-3189: Fix intermittent "transaction expired" error when committin…
Browse files Browse the repository at this point in the history
…g a distributed transaction

Summary: In transaction coordinator, the last_touch_ time of a transaction may be skewed compared to the coordinator's clock. Sometimes the last_touch_ time may go after the coordinator's clock and thus an underflow error when last_touch_ time is subtracted from now() in TransactionState::ExpiredAt() and the transaction erroneously considered expired.

Test Plan:
Run CassandraTransactionalKeyValue read/write workload with 1000000 keys inserted in a GCP cluster with no "transaction expired" error.

```
java -jar ~/code/yugabyte/java/yb-loadtester/target/yb-sample-apps.jar -workload CassandraTransactionalKeyValue -num_threads_read 64 -num_threads_write 8 -nodes ...
```

Reviewers: mikhail, sergei

Reviewed By: sergei

Differential Revision: https://phabricator.dev.yugabyte.com/D4615
  • Loading branch information
robertpang committed Apr 15, 2018
1 parent 7f61b63 commit 7020d08
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/yb/client/ql-transaction-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

using namespace std::literals; // NOLINT

DECLARE_uint64(transaction_timeout_usec);
DECLARE_int64(transaction_timeout_usec);
DECLARE_uint64(transaction_heartbeat_usec);
DECLARE_uint64(transaction_table_num_tablets);
DECLARE_uint64(log_segment_size_bytes);
Expand Down
4 changes: 2 additions & 2 deletions src/yb/tablet/transaction_coordinator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
#include "yb/util/tsan_util.h"

DECLARE_uint64(transaction_heartbeat_usec);
DEFINE_uint64(transaction_timeout_usec, 1500000, "Transaction expiration timeout in usec.");
DEFINE_int64(transaction_timeout_usec, 1500000, "Transaction expiration timeout in usec.");
DEFINE_uint64(transaction_check_interval_usec, 500000, "Transaction check interval in usec.");
DEFINE_double(transaction_ignore_applying_probability_in_tests, 0,
"Probability to ignore APPLYING update in tests.");
Expand Down Expand Up @@ -149,7 +149,7 @@ class TransactionState {
if (ShouldBeCommitted()) {
return false;
}
auto passed = now.GetPhysicalValueMicros() - last_touch_.GetPhysicalValueMicros();
const int64_t passed = now.GetPhysicalValueMicros() - last_touch_.GetPhysicalValueMicros();
return passed > FLAGS_transaction_timeout_usec;
}

Expand Down

0 comments on commit 7020d08

Please sign in to comment.