Concurrency issues during Update commit
1) Issue: "Chunked_vec.hpp::at()" throws an exception, which it is not expected to do so.
[NOTE: Some times test passes, but most of the times it fails. When concurrency is removed, everything works fine]
2) Line num : https://dbgit.prakinf.tu-ilmenau.de/code/poseidon_core/-/blob/master/src/storage/chunked_vec.hpp#L453
OR
3) Scenario :
- Try to create a node and abort it without committing.
- In another thread, create two separate nodes successfully.
- Finally do an update on any one of the created nodes.
4) How to reproduce the issue ?
Steps : Added the following Test case at beginning of "../../test/transaction_test.cpp" ( commented-out all remaining test cases)
TEST_CASE("Test write abort" "[transaction]") {
#ifdef USE_PMDK
auto pop = prepare_pool();
auto gdb = create_graph_db(pop);
#else
auto gdb = create_graph_db();
#endif
node::id_t Actor_nid{}, Director_nid{}, Producer_nid{};
barrier tx1_aborted{};
auto t1 = std::thread( [&] () {
//Txn -1 , add "Actor" but abort it without committing
auto tx = gdb->begin_transaction();
Actor_nid = gdb->add_node("Actor",
{{"name", boost::any(std::string("Mark the Actor"))},
{"age", boost::any(29)}});
gdb->abort_transaction();
tx1_aborted.notify();
});
auto t2 = std::thread( [&] () { // Should succeed
// Txn -2 , add "Producer", add "Director"
// create node
auto tx = gdb->begin_transaction();
//add node
Producer_nid = gdb->add_node("Producer",
{{"name", boost::any(std::string("Paul the producer"))},
{"age", boost::any(55)}});
//add node
Director_nid = gdb->add_node("Director",
{{"name", boost::any(std::string("Daniel the director"))},
{"age", boost::any(61)}});
tx1_aborted.wait();
gdb->commit_transaction();
} );
//--------------------------------------------
t1.join();
t2.join();
// Txn -3 , update "Director". Should succeed but fails
{ auto tx = gdb->begin_transaction();
auto &n = gdb->node_by_id(Director_nid);
//update node :
gdb->update_node(n,
{{
"age", boost::any(67),
}},
"Updated Director by Tx-3"); // label
gdb->commit_transaction(); //**<========================= fails here during commit**
}
gdb->dump();
#ifdef USE_PMDK
drop_graph_db(pop, gdb);
#endif
}
5) Output : Below is a debug output
arth0746@dbpmem:~/06june_poseidon_test_concurr_issue/poseidon_core/build/test$ ./transaction_test
Test write abort[transaction]
/home/arth0746/06june_poseidon_test_concurr_issue/poseidon_core/test/transaction_test.cpp:145
/home/arth0746/06june_poseidon_test_concurr_issue/poseidon_core/test/transaction_test.cpp:145: FAILED:
due to unexpected exception with message:
Node or relationship does not exist.
===============================================================================
test cases: 1 | 1 failed
assertions: 1 | 1 failed
**The same test "passes" some times as shown below :**
arth0746@dbpmem:~/06june_poseidon_test_concurr_issue/poseidon_core/build/test$ ./transaction_test
----------- NODES -----------
0,@140548152501328 [ txn-id=0, bts=3175, cts=-1, dirty=0 ], label=9, from=18446744073709551615, to=18446744073709551615, props=1
1, @140548152501384 [ txn-id=0, bts=60576, cts=-1, dirty=0 ], label=2, from=18446744073709551615, to=18446744073709551615, props=0
-----------------------------
------- RELATIONSHIPS -------
-----------------------------
===============================================================================
test cases: 1 | 1 passed
assertions: - none -
6) Issue Description : The exception occurs during the commit of update transaction i.e during Txn -3 , update "Director"