memgraph/tests/unit
Matija Santl 5d5dfbb6f7 Fix how HA handles leader change during commit
Summary:
During it's leadership, one peer can receive RPC messages from other peers that his reign is over.
The problem is when this happens during a transaction commit.

This is handled in the following way.
If we're the current leader and we want to commit a transaction, we need to make sure the Raft Log is replicated before we can tell the client that the transaction is committed.
During that wait, we can only notice that the replication takes too long, and we report that with `LOG(WARNING)` messages.

If we change the Raft mode during the wait, our Raft implementation will internally commit this transaction, but won't be able to acquire the Raft lock because the `db.Reset` has been called.
This is why there is an manual lock acquire. If we pick up that the `db.Reset` has been called, we throw an `UnexpectedLeaderChangeException` exception to the client.

Another thing with long running transactions, if someone decides to kill a `memgraph_ha` instance during the commit, the transaction will have `abort` hint set. This will cause the `src/query/operator.cpp` to throw a `HintedAbortError`. We need to catch this during the shutdown, because the `memgraph_ha` isn't dead from the user perspective, and the transaction wasn't aborted because it took too long, but we can differentiate between those two.

Reviewers: mferencevic, ipaljak

Reviewed By: mferencevic, ipaljak

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D1956
2019-05-20 16:39:44 +02:00
..
ast_serialization.cpp Remove Cap'n Proto 2019-05-08 10:51:10 +02:00
auth.cpp Migrate to C++17 2019-04-23 14:46:44 +02:00
bfs_common.hpp Allocate Cursor through utils::MemoryResource 2019-05-13 11:36:40 +02:00
bfs_distributed.cpp Move distributed query stuff to new folder 2019-04-24 09:34:53 +02:00
bfs_single_node.cpp Migrate to C++17 2019-04-23 14:46:44 +02:00
bolt_chunked_decoder_buffer.cpp Refactor network stack to use * instead of & 2018-09-03 20:20:42 +02:00
bolt_chunked_encoder_buffer.cpp Support streaming of Bolt results 2018-07-18 13:01:50 +02:00
bolt_common.hpp Support streaming of Bolt results 2018-07-18 13:01:50 +02:00
bolt_decoder.cpp Rename bolt::DecodedValue to bolt::Value 2018-07-24 15:59:20 +02:00
bolt_encoder.cpp Move GraphDbAccessor to stack in SN and HA 2019-04-17 11:29:43 +02:00
bolt_session.cpp Refactor network stack to use * instead of & 2018-09-03 20:20:42 +02:00
bolt_testdata.hpp Removed large bolt encoder test to reduce runtime. 2017-05-03 14:50:02 +02:00
cache.cpp Add LruCache implementation and tests 2019-02-14 11:03:33 +01:00
CMakeLists.txt Add multiple properties unique constraint 2019-05-20 15:18:05 +02:00
communication_buffer.cpp Refactor network stack to use * instead of & 2018-09-03 20:20:42 +02:00
concurrent_id_mapper_distributed.cpp Add SSL support to HA RPC 2019-05-20 12:53:52 +02:00
concurrent_id_mapper_single_node.cpp Refactor storage file structure 2018-11-06 18:17:31 +01:00
concurrent_map_access.cpp Const map/set iteration. 2017-10-12 16:35:39 +02:00
concurrent_map.cpp Clean SkipList up 2018-04-11 10:08:20 +02:00
cypher_main_visitor.cpp Migrate to C++17 2019-04-23 14:46:44 +02:00
database_dump.cpp Dump indices in CypherDumpGenerator 2019-05-15 11:05:16 +02:00
database_key_index.cpp Move GraphDbAccessor to stack in SN and HA 2019-04-17 11:29:43 +02:00
database_label_property_index.cpp Move GraphDbAccessor to stack in SN and HA 2019-04-17 11:29:43 +02:00
database_master.cpp Separate distributed from single node GraphDb 2018-10-05 13:32:05 +02:00
database_transaction_timeout.cpp Move GraphDbAccessor to stack in SN and HA 2019-04-17 11:29:43 +02:00
datastructure_union_find.cpp Add parallel customers/Otto test 2017-11-23 09:20:53 +01:00
deferred_deleter.cpp Refactor storage file structure 2018-11-06 18:17:31 +01:00
distributed_common.hpp Migrate to C++17 2019-04-23 14:46:44 +02:00
distributed_coordination.cpp Migrate to C++17 2019-04-23 14:46:44 +02:00
distributed_data_exchange.cpp Add CachedDataLock throughout the code 2019-02-21 15:27:40 +01:00
distributed_dgp_partitioner.cpp Add dgp integration test 2018-09-08 00:01:03 +01:00
distributed_dgp_vertex_migrator.cpp Migrate to C++17 2019-04-23 14:46:44 +02:00
distributed_durability.cpp Migrate to C++17 2019-04-23 14:46:44 +02:00
distributed_dynamic_worker.cpp Migrate to C++17 2019-04-23 14:46:44 +02:00
distributed_edges_iterator.cpp Migrate to C++17 2019-04-23 14:46:44 +02:00
distributed_gc.cpp Separate distributed implementation of GraphDbAccessor 2018-07-26 09:16:39 +02:00
distributed_graph_db.cpp Reimplement counter openCypher function 2019-05-16 11:09:02 +02:00
distributed_interpretation.cpp Move distributed query stuff to new folder 2019-04-24 09:34:53 +02:00
distributed_plan_pretty_print.cpp Move distributed query stuff to new folder 2019-04-24 09:34:53 +02:00
distributed_query_plan.cpp Remove Cap'n Proto 2019-05-08 10:51:10 +02:00
distributed_reset.cpp Use utils::MonotonicBufferResource in query execution 2019-05-13 11:36:19 +02:00
distributed_serialization.cpp Rewrite distributed_serialization test to use SLK 2019-05-06 10:51:32 +02:00
distributed_updates.cpp Migrate to C++17 2019-04-23 14:46:44 +02:00
durability.cpp Add multiple properties unique constraint 2019-05-20 15:18:05 +02:00
dynamic_bitset.cpp Commit log gc 2018-04-04 10:25:25 +02:00
edges_distributed.cpp Migrate to C++17 2019-04-23 14:46:44 +02:00
edges_single_node.cpp Fix filtering of edges by edge type and destination 2019-01-14 17:31:40 +01:00
gid.cpp Separate distributed from single node storage 2018-10-05 09:19:33 +02:00
graph_db_accessor_index_api.cpp Add multiple properties unique constraint 2019-05-20 15:18:05 +02:00
graph_db_accessor.cpp Migrate to C++17 2019-04-23 14:46:44 +02:00
graph_db.cpp Move GraphDbAccessor to stack in SN and HA 2019-04-17 11:29:43 +02:00
interpreter.cpp Add multiple properties unique constraint 2019-05-20 15:18:05 +02:00
kvstore.cpp Migrate to C++17 2019-04-23 14:46:44 +02:00
metrics.cpp Migrate to C++17 2019-04-23 14:46:44 +02:00
mvcc_find_update_common.hpp Refactor storage file structure 2018-11-06 18:17:31 +01:00
mvcc_find.cpp GC bugfixes, MVCC and transaction refactoring 2017-06-12 10:46:12 +02:00
mvcc_gc_common.hpp Refactor storage file structure 2018-11-06 18:17:31 +01:00
mvcc_gc.cpp Refactor storage file structure 2018-11-06 18:17:31 +01:00
mvcc_one_transaction.cpp Fix mvcc tests 2017-10-19 12:58:23 +02:00
mvcc_parallel_update.cpp Fix mvcc tests 2017-10-19 12:58:23 +02:00
mvcc.cpp Refactor storage file structure 2018-11-06 18:17:31 +01:00
network_endpoint.cpp Rename NetworkEndpoint 2018-01-15 15:47:37 +01:00
network_timeouts.cpp Add explicit start to servers 2018-10-16 11:39:42 +02:00
network_utils.cpp Extract utils into mg-utils static library and explicitly list tests 2018-05-30 09:41:56 +02:00
plan_pretty_print.cpp Migrate to C++17 2019-04-23 14:46:44 +02:00
pod_buffer.cpp Separate distributed from single node storage 2018-10-05 09:19:33 +02:00
property_value_store.cpp Migrate to C++17 2019-04-23 14:46:44 +02:00
query_common.hpp Migrate to C++17 2019-04-23 14:46:44 +02:00
query_cost_estimator.cpp Migrate to C++17 2019-04-23 14:46:44 +02:00
query_expression_evaluator.cpp Reimplement counter openCypher function 2019-05-16 11:09:02 +02:00
query_plan_accumulate_aggregate.cpp Move GraphDbAccessor to stack in SN and HA 2019-04-17 11:29:43 +02:00
query_plan_bag_semantics.cpp Move GraphDbAccessor to stack in SN and HA 2019-04-17 11:29:43 +02:00
query_plan_checker.hpp Migrate to C++17 2019-04-23 14:46:44 +02:00
query_plan_common.hpp Use utils::MonotonicBufferResource in query execution 2019-05-13 11:36:19 +02:00
query_plan_create_set_remove_delete.cpp Use utils::MonotonicBufferResource in query execution 2019-05-13 11:36:19 +02:00
query_plan_edge_cases.cpp Migrate to C++17 2019-04-23 14:46:44 +02:00
query_plan_match_filter_return.cpp Use utils::MonotonicBufferResource in query execution 2019-05-13 11:36:19 +02:00
query_plan.cpp Migrate to C++17 2019-04-23 14:46:44 +02:00
query_pretty_print.cpp Move GraphDbAccessor to stack in SN and HA 2019-04-17 11:29:43 +02:00
query_profile.cpp Output profiling data within the summary in JSON format 2019-01-17 13:54:06 +01:00
query_required_privileges.cpp Add grammar for unique constraints 2019-03-28 16:48:16 +01:00
query_semantic.cpp Move GraphDbAccessor to stack in SN and HA 2019-04-17 11:29:43 +02:00
query_variable_start_planner.cpp Move GraphDbAccessor to stack in SN and HA 2019-04-17 11:29:43 +02:00
queue.cpp Migrate to C++17 2019-04-23 14:46:44 +02:00
record_edge_vertex_accessor.cpp Move GraphDbAccessor to stack in SN and HA 2019-04-17 11:29:43 +02:00
replication_log.cpp Fix Raft's ReplicationLog 2019-01-23 16:27:51 +01:00
ring_buffer.cpp Extract io/network into mg-io library 2018-05-30 14:58:41 +02:00
rpc_messages.hpp Migrate RPC to SLK 2019-05-06 14:27:57 +02:00
rpc.cpp Add SSL support to HA RPC 2019-05-20 12:53:52 +02:00
skip_list.cpp Migrate to C++17 2019-04-23 14:46:44 +02:00
skiplist_access.cpp Const map/set iteration. 2017-10-12 16:35:39 +02:00
skiplist_gc.cpp Remove executor not run option 2017-12-18 14:36:15 +01:00
skiplist_position_and_count.cpp Replace debug_assert, permanent_assert with DCHECK/CHECK 2017-10-11 14:43:32 +02:00
skiplist_reverse_iteration.cpp Logger in this test somehow breaks code coverage. Argh... 2017-04-07 09:44:12 +02:00
skiplist_suffix.cpp Separate distributed from single node storage 2018-10-05 09:19:33 +02:00
slk_advanced.cpp Finish SLK implementation 2019-05-02 15:47:38 +02:00
slk_common.hpp Finish SLK implementation 2019-05-02 15:47:38 +02:00
slk_core.cpp Finish SLK implementation 2019-05-02 15:47:38 +02:00
slk_streams.cpp Finish SLK implementation 2019-05-02 15:47:38 +02:00
small_vector.cpp Migrate to C++17 2019-04-23 14:46:44 +02:00
socket.cpp Implement SSL support for servers and clients 2018-06-20 17:56:47 +02:00
state_delta.cpp Move GraphDbAccessor to stack in SN and HA 2019-04-17 11:29:43 +02:00
static_bitset.cpp Fix tests that expect debug_assert to fail 2017-08-07 16:38:15 +02:00
storage_address.cpp Separate distributed from single node storage 2018-10-05 09:19:33 +02:00
storage_stat.cpp Move GraphDbAccessor to stack in SN and HA 2019-04-17 11:29:43 +02:00
stripped.cpp Fix line comment stripping in query stripper 2019-01-18 13:24:02 +01:00
test_coordination.hpp Add explicit start to servers 2018-10-16 11:39:42 +02:00
test_lcp.lisp LCP: Small test fixes 2019-05-10 16:10:17 +02:00
transaction_engine_distributed.cpp Remove ConcurrentMap from RPC 2018-10-18 10:04:55 +02:00
transaction_engine_single_node_ha.cpp Fix how HA handles leader change during commit 2019-05-20 16:39:44 +02:00
transaction_engine_single_node.cpp Migrate to C++17 2019-04-23 14:46:44 +02:00
typed_value.cpp Move GraphDbAccessor to stack in SN and HA 2019-04-17 11:29:43 +02:00
unique_constraints.cpp Add multiple properties unique constraint 2019-05-20 15:18:05 +02:00
utils_algorithm.cpp Add new PrintIterable to utils algorithm 2019-05-06 14:51:32 +02:00
utils_demangle.cpp Extract utils into mg-utils static library and explicitly list tests 2018-05-30 09:41:56 +02:00
utils_exceptions.cpp Extract utils into mg-utils static library and explicitly list tests 2018-05-30 09:41:56 +02:00
utils_executor.cpp Extract utils into mg-utils static library and explicitly list tests 2018-05-30 09:41:56 +02:00
utils_file.cpp Migrate to C++17 2019-04-23 14:46:44 +02:00
utils_math.cpp Add logarithmic functions 2019-01-17 14:26:16 +01:00
utils_memory.cpp Implement MonotonicBufferResource 2019-05-06 16:02:30 +02:00
utils_on_scope_exit.cpp utils::auto_scope refactor 2017-08-11 09:43:10 +02:00
utils_rwlock.cpp Extract io/network into mg-io library 2018-05-30 14:58:41 +02:00
utils_scheduler.cpp Extract utils into mg-utils static library and explicitly list tests 2018-05-30 09:41:56 +02:00
utils_signals.cpp Extract utils into mg-utils static library and explicitly list tests 2018-05-30 09:41:56 +02:00
utils_string.cpp Remove keyword lowercasing from stripper 2018-07-19 17:08:45 +02:00
utils_thread_pool.cpp Throw exceptions on RPC failure and Distributed error handling 2018-09-27 16:27:40 +02:00
utils_timestamp.cpp Extract utils into mg-utils static library and explicitly list tests 2018-05-30 09:41:56 +02:00
utils_watchdog.cpp Extract utils into mg-utils static library and explicitly list tests 2018-05-30 09:41:56 +02:00