Compare commits
4 Commits
MG_show_da
...
interleave
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a7628a40c7 | ||
|
|
1b06684aa8 | ||
|
|
3c66b1b350 | ||
|
|
3063f71074 |
@@ -132,7 +132,7 @@ State HandlePullDiscardV4(TSession &session, const State state, const Marker mar
|
|||||||
return State::Close;
|
return State::Close;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state != State::Result) {
|
if (state != State::Result && state != State::Idle) {
|
||||||
if constexpr (is_pull) {
|
if constexpr (is_pull) {
|
||||||
spdlog::trace("Unexpected PULL!");
|
spdlog::trace("Unexpected PULL!");
|
||||||
} else {
|
} else {
|
||||||
@@ -264,7 +264,7 @@ State HandleRunV4(TSession &session, const State state, const Marker marker) {
|
|||||||
return State::Close;
|
return State::Close;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state != State::Idle) {
|
if (state != State::Idle && state != State::Result) {
|
||||||
// Client could potentially recover if we move to error state, but there is
|
// Client could potentially recover if we move to error state, but there is
|
||||||
// no legitimate situation in which well working client would end up in this
|
// no legitimate situation in which well working client would end up in this
|
||||||
// situation.
|
// situation.
|
||||||
|
|||||||
23
tests/drivers/python/v5_8/explicit_tx_multiple_run.py
Normal file
23
tests/drivers/python/v5_8/explicit_tx_multiple_run.py
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
from typing import Set
|
||||||
|
|
||||||
|
import neo4j
|
||||||
|
|
||||||
|
MEMGRAPH_URL = "bolt://localhost:7687"
|
||||||
|
|
||||||
|
driver = neo4j.GraphDatabase.driver(MEMGRAPH_URL, auth=("", ""))
|
||||||
|
|
||||||
|
|
||||||
|
def fill_db(tx):
|
||||||
|
tx.run("UNWIND range(1, 2000) AS i CREATE (n:Node {id: i}) RETURN n")
|
||||||
|
|
||||||
|
|
||||||
|
def run_queries(tx):
|
||||||
|
tx.run("match (n) return n;") # A query that forces the result to have has_more=true
|
||||||
|
tx.run("match (n) return n limit 1;") # Any query you can run
|
||||||
|
|
||||||
|
|
||||||
|
with driver.session() as session:
|
||||||
|
tx = session.begin_transaction()
|
||||||
|
fill_db(tx)
|
||||||
|
run_queries(tx)
|
||||||
|
tx.commit()
|
||||||
@@ -26,4 +26,5 @@ python3 max_query_length.py || exit 1
|
|||||||
python3 transactions.py || exit 1
|
python3 transactions.py || exit 1
|
||||||
python3 path.py || exit 1
|
python3 path.py || exit 1
|
||||||
python3 server_name.py || exit 1
|
python3 server_name.py || exit 1
|
||||||
|
python3 explicit_tx_multiple_run.py || exit 1
|
||||||
# python3 parallel_edge_import.py || exit 1
|
# python3 parallel_edge_import.py || exit 1
|
||||||
|
|||||||
@@ -177,6 +177,8 @@ inline constexpr uint8_t pullall_req[] = {0xb1, 0x3f, 0xa0};
|
|||||||
inline constexpr uint8_t pull_one_req[] = {0xb1, 0x3f, 0xa1, 0x81, 0x6e, 0x01};
|
inline constexpr uint8_t pull_one_req[] = {0xb1, 0x3f, 0xa1, 0x81, 0x6e, 0x01};
|
||||||
inline constexpr uint8_t reset_req[] = {0xb0, 0x0f};
|
inline constexpr uint8_t reset_req[] = {0xb0, 0x0f};
|
||||||
inline constexpr uint8_t goodbye[] = {0xb0, 0x02};
|
inline constexpr uint8_t goodbye[] = {0xb0, 0x02};
|
||||||
|
inline constexpr uint8_t begin[] = {0xb1, 0x11, 0xa0};
|
||||||
|
inline constexpr uint8_t commit[] = {0xb0, 0x12};
|
||||||
inline constexpr uint8_t rollback[] = {0xb0, 0x13};
|
inline constexpr uint8_t rollback[] = {0xb0, 0x13};
|
||||||
} // namespace v4
|
} // namespace v4
|
||||||
|
|
||||||
@@ -208,7 +210,6 @@ constexpr std::string_view extra_w_127ms_timeout =
|
|||||||
"\x8a\x74\x78\x5F\x74\x69\x6D\x65\x6F\x75\x74" // String size 10 "tx_timeout"
|
"\x8a\x74\x78\x5F\x74\x69\x6D\x65\x6F\x75\x74" // String size 10 "tx_timeout"
|
||||||
"\x7f"; // Integer 127 (representing 127ms)
|
"\x7f"; // Integer 127 (representing 127ms)
|
||||||
|
|
||||||
inline constexpr uint8_t commit[] = {0xb0, 0x12};
|
|
||||||
} // namespace v4_3
|
} // namespace v4_3
|
||||||
|
|
||||||
// Write bolt chunk header (length)
|
// Write bolt chunk header (length)
|
||||||
@@ -280,6 +281,21 @@ void ExecuteInit(TestInputStream &input_stream, TestSession &session, std::vecto
|
|||||||
CheckOutput(output, response, 28);
|
CheckOutput(output, response, 28);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ExecuteBeginTransaction(TestInputStream &input_stream, TestSession &session, std::vector<uint8_t> &output) {
|
||||||
|
const auto *request = v4::begin;
|
||||||
|
const auto request_size = sizeof(v4::begin);
|
||||||
|
ExecuteCommand(input_stream, session, request, request_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExecuteCommitTransaction(TestInputStream &input_stream, TestSession &session, std::vector<uint8_t> &output) {
|
||||||
|
const auto *request = v4::commit;
|
||||||
|
const auto request_size = sizeof(v4::commit);
|
||||||
|
ExecuteCommand(input_stream, session, request, request_size);
|
||||||
|
ASSERT_EQ(session.state_, State::Idle);
|
||||||
|
PrintOutput(output);
|
||||||
|
CheckSuccessMessage(output);
|
||||||
|
}
|
||||||
|
|
||||||
// Write bolt encoded run request
|
// Write bolt encoded run request
|
||||||
void WriteRunRequest(TestInputStream &input_stream, const char *str, const bool is_v4 = false,
|
void WriteRunRequest(TestInputStream &input_stream, const char *str, const bool is_v4 = false,
|
||||||
std::string_view extra = "\xA0") {
|
std::string_view extra = "\xA0") {
|
||||||
@@ -1228,3 +1244,81 @@ TEST(BoltSession, PartialStream) {
|
|||||||
EXPECT_NE(find_msg, cend(output));
|
EXPECT_NE(find_msg, cend(output));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(BoltSession, ExplicitTxBeginAndCommit) {
|
||||||
|
{
|
||||||
|
INIT_VARS;
|
||||||
|
|
||||||
|
ExecuteHandshake(input_stream, session, output, v4_3::handshake_req, v4_3::handshake_resp);
|
||||||
|
ExecuteInit(input_stream, session, output, true);
|
||||||
|
ExecuteBeginTransaction(input_stream, session, output);
|
||||||
|
ExecuteCommitTransaction(input_stream, session, output);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(BoltSession, ExplicitTxBeginRunPullCommit) {
|
||||||
|
{
|
||||||
|
INIT_VARS;
|
||||||
|
|
||||||
|
ExecuteHandshake(input_stream, session, output, v4_3::handshake_req, v4_3::handshake_resp);
|
||||||
|
ExecuteInit(input_stream, session, output, true);
|
||||||
|
ExecuteBeginTransaction(input_stream, session, output);
|
||||||
|
WriteRunRequest(input_stream, kQueryReturn42, true, v4_3::extra_w_metadata);
|
||||||
|
session.Execute();
|
||||||
|
ASSERT_EQ(session.state_, State::Result);
|
||||||
|
ExecuteCommand(input_stream, session, v4::pull_one_req, sizeof(v4::pull_one_req));
|
||||||
|
ASSERT_EQ(session.state_, State::Idle);
|
||||||
|
ExecuteCommitTransaction(input_stream, session, output);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(BoltSession, ExplicitTxBeginRunPullAllCommit) {
|
||||||
|
{
|
||||||
|
INIT_VARS;
|
||||||
|
|
||||||
|
ExecuteHandshake(input_stream, session, output, v4_3::handshake_req, v4_3::handshake_resp);
|
||||||
|
ExecuteInit(input_stream, session, output, true);
|
||||||
|
ExecuteBeginTransaction(input_stream, session, output);
|
||||||
|
|
||||||
|
WriteRunRequest(input_stream, kQueryReturn42, true, v4_3::extra_w_metadata);
|
||||||
|
session.Execute();
|
||||||
|
ASSERT_EQ(session.state_, State::Result);
|
||||||
|
ExecuteCommand(input_stream, session, v4::pull_one_req, sizeof(v4::pull_one_req));
|
||||||
|
ASSERT_EQ(session.state_, State::Idle);
|
||||||
|
|
||||||
|
WriteRunRequest(input_stream, kQueryReturnMultiple, true, v4_3::extra_w_metadata);
|
||||||
|
session.Execute();
|
||||||
|
ASSERT_EQ(session.state_, State::Result);
|
||||||
|
ExecuteCommand(input_stream, session, v4::pullall_req, sizeof(v4::pullall_req));
|
||||||
|
ASSERT_EQ(session.state_, State::Idle);
|
||||||
|
constexpr std::array<uint8_t, 10> md_has_more_true{0x88, 0x68, 0x61, 0x73, 0x5F, 0x6D, 0x6F, 0x72, 0x65, 0xC3};
|
||||||
|
auto find_has_more = std::search(cbegin(output), cend(output), cbegin(md_has_more_true), cend(md_has_more_true));
|
||||||
|
EXPECT_EQ(find_has_more, cend(output));
|
||||||
|
|
||||||
|
ExecuteCommitTransaction(input_stream, session, output);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(BoltSession, ExplicitTxBeginRunRunPullAllCommit) {
|
||||||
|
{
|
||||||
|
INIT_VARS;
|
||||||
|
|
||||||
|
ExecuteHandshake(input_stream, session, output, v4_3::handshake_req, v4_3::handshake_resp);
|
||||||
|
ExecuteInit(input_stream, session, output, true);
|
||||||
|
ExecuteBeginTransaction(input_stream, session, output);
|
||||||
|
|
||||||
|
WriteRunRequest(input_stream, kQueryReturn42, true, v4_3::extra_w_metadata);
|
||||||
|
session.Execute();
|
||||||
|
ASSERT_EQ(session.state_, State::Result);
|
||||||
|
WriteRunRequest(input_stream, kQueryReturnMultiple, true, v4_3::extra_w_metadata);
|
||||||
|
session.Execute();
|
||||||
|
ASSERT_EQ(session.state_, State::Result);
|
||||||
|
ExecuteCommand(input_stream, session, v4::pull_one_req, sizeof(v4::pullall_req));
|
||||||
|
ASSERT_EQ(session.state_, State::Idle);
|
||||||
|
constexpr std::array<uint8_t, 10> md_has_more_true{0x88, 0x68, 0x61, 0x73, 0x5F, 0x6D, 0x6F, 0x72, 0x65, 0xC3};
|
||||||
|
auto find_has_more = std::search(cbegin(output), cend(output), cbegin(md_has_more_true), cend(md_has_more_true));
|
||||||
|
EXPECT_EQ(find_has_more, cend(output));
|
||||||
|
|
||||||
|
ExecuteCommitTransaction(input_stream, session, output);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user