From fb0fa4223dbc31c3ae02e4230405c57ecb33632b Mon Sep 17 00:00:00 2001 From: Wang Zhiyong Date: Wed, 9 Oct 2024 06:41:55 +0000 Subject: [PATCH] fix lgraph_cli exception --- src/bolt/pack_stream.h | 4 ++++ toolkits/lgraph_cli.cpp | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/bolt/pack_stream.h b/src/bolt/pack_stream.h index e16f5eef69..e482e11f62 100644 --- a/src/bolt/pack_stream.h +++ b/src/bolt/pack_stream.h @@ -221,6 +221,10 @@ class PackStream { AppendStructMessage(BoltMsg::Ignored); } + void AppendReset() { + AppendStructMessage(BoltMsg::Reset); + } + void AppendFailure(const std::unordered_map& meta) { AppendStructMessage(BoltMsg::Failure, meta); } diff --git a/toolkits/lgraph_cli.cpp b/toolkits/lgraph_cli.cpp index 7459c19bc5..9883f5b128 100644 --- a/toolkits/lgraph_cli.cpp +++ b/toolkits/lgraph_cli.cpp @@ -283,6 +283,23 @@ int main(int argc, char** argv) { asio::write(socket, asio::const_buffer(ps.ConstBuffer().data(), ps.ConstBuffer().size())); bool ret = FetchRecords(socket, hydrator, of); + if (!ret) { + // reset connection + ps.Reset(); + ps.AppendReset(); + asio::write(socket,asio::const_buffer(ps.ConstBuffer().data(), ps.ConstBuffer().size())); + while(true) { + auto m = ReadMessage(socket, hydrator); + if (m.type() == typeid(bolt::Success*)) { + break; + } else if (m.type() == typeid(bolt::Ignored*)) { + continue; + } else { + LOG_ERROR() << "unexpected bolt msg after reset"; + return -1; + } + } + } if (is_terminal && ret) { linenoiseHistoryAdd(statement.c_str()); linenoiseHistorySave(history_file);