Skip to content

Commit

Permalink
Fix lgraph_cli hang after a error query (TuGraph-family#692)
Browse files Browse the repository at this point in the history
* fix lgraph_cli exception

* add auth error log

* fix cpplint

* update tabulate version
  • Loading branch information
ljcui authored Oct 9, 2024
1 parent 0d55216 commit f625d40
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 9 deletions.
4 changes: 2 additions & 2 deletions ci/images/tugraph-compile-arm64v8-centos7-Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,8 @@ RUN wget https://tugraph-web.oss-cn-beijing.aliyuncs.com/tugraph/deps/graphar/Gr
# tabulate
# if it is not accessible, replace it with the link below
# https://github.com/p-ranav/tabulate/archive/refs/tags/v1.5.tar.gz
RUN wget https://tugraph-web.oss-cn-beijing.aliyuncs.com/tugraph/deps/tabulate-d553e5.tar.gz \
&& tar zxf tabulate-d553e5.tar.gz && cp -rf tabulate-d553e5/include/tabulate /usr/local/include \
RUN wget https://tugraph-web.oss-cn-beijing.aliyuncs.com/tugraph/deps/tabulate-3a5830.tar.gz \
&& tar zxf tabulate-3a5830.tar.gz && cp -rf tabulate/include/tabulate /usr/local/include \
&& rm -rf /tabulate*

RUN sed -i '3 s/-lgomp/-l:libgomp.a/' /usr/local/lib64/libgomp.spec
Expand Down
4 changes: 2 additions & 2 deletions ci/images/tugraph-compile-centos7-Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,8 @@ RUN wget https://tugraph-web.oss-cn-beijing.aliyuncs.com/tugraph/deps/graphar/Gr
# tabulate
# if it is not accessible, replace it with the link below
# https://github.com/p-ranav/tabulate/archive/refs/tags/v1.5.tar.gz
RUN wget https://tugraph-web.oss-cn-beijing.aliyuncs.com/tugraph/deps/tabulate-d553e5.tar.gz \
&& tar zxf tabulate-d553e5.tar.gz && cp -rf tabulate-d553e5/include/tabulate /usr/local/include \
RUN wget https://tugraph-web.oss-cn-beijing.aliyuncs.com/tugraph/deps/tabulate-3a5830.tar.gz \
&& tar zxf tabulate-3a5830.tar.gz && cp -rf tabulate/include/tabulate /usr/local/include \
&& rm -rf /tabulate*

RUN sed -i '3 s/-lgomp/-l:libgomp.a/' /usr/local/lib64/libgomp.spec
Expand Down
4 changes: 2 additions & 2 deletions ci/images/tugraph-compile-centos8-Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,8 @@ RUN wget https://tugraph-web.oss-cn-beijing.aliyuncs.com/tugraph/deps/graphar/Gr
# tabulate
# if it is not accessible, replace it with the link below
# https://github.com/p-ranav/tabulate/archive/refs/tags/v1.5.tar.gz
RUN wget https://tugraph-web.oss-cn-beijing.aliyuncs.com/tugraph/deps/tabulate-d553e5.tar.gz \
&& tar zxf tabulate-d553e5.tar.gz && cp -rf tabulate-d553e5/include/tabulate /usr/local/include \
RUN wget https://tugraph-web.oss-cn-beijing.aliyuncs.com/tugraph/deps/tabulate-3a5830.tar.gz \
&& tar zxf tabulate-3a5830.tar.gz && cp -rf tabulate/include/tabulate /usr/local/include \
&& rm -rf /tabulate*

RUN sed -i '3 s/-lgomp/-l:libgomp.a/' /usr/local/lib64/libgomp.spec
Expand Down
4 changes: 2 additions & 2 deletions ci/images/tugraph-compile-ubuntu18.04-Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,8 @@ RUN wget https://tugraph-web.oss-cn-beijing.aliyuncs.com/tugraph/deps/graphar/Gr
# tabulate
# if it is not accessible, replace it with the link below
# https://github.com/p-ranav/tabulate/archive/refs/tags/v1.5.tar.gz
RUN wget https://tugraph-web.oss-cn-beijing.aliyuncs.com/tugraph/deps/tabulate-d553e5.tar.gz \
&& tar zxf tabulate-d553e5.tar.gz && cp -rf tabulate-d553e5/include/tabulate /usr/local/include \
RUN wget https://tugraph-web.oss-cn-beijing.aliyuncs.com/tugraph/deps/tabulate-3a5830.tar.gz \
&& tar zxf tabulate-3a5830.tar.gz && cp -rf tabulate/include/tabulate /usr/local/include \
&& rm -rf /tabulate*

RUN sed -i '3 s/-lgomp/-l:libgomp.a/' /usr/local/lib64/libgomp.spec
Expand Down
4 changes: 4 additions & 0 deletions src/bolt/pack_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,10 @@ class PackStream {
AppendStructMessage(BoltMsg::Ignored);
}

void AppendReset() {
AppendStructMessage(BoltMsg::Reset);
}

void AppendFailure(const std::unordered_map<std::string, std::any>& meta) {
AppendStructMessage(BoltMsg::Failure, meta);
}
Expand Down
3 changes: 2 additions & 1 deletion src/server/bolt_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,8 @@ std::function<void(bolt::BoltConnection &conn, bolt::BoltMsg msg,
auto& credentials = std::any_cast<const std::string&>(val.at("credentials"));
auto galaxy = BoltServer::Instance().StateMachine()->GetGalaxy();
if (!galaxy->ValidateUser(principal, credentials)) {
LOG_ERROR() << "Bolt authentication failed";
LOG_ERROR() << FMA_FMT(
"Bolt authentication failed, user:{}, password:{}", principal, credentials);
bolt::PackStream ps;
ps.AppendFailure({{"code", "error"},
{"message", "Authentication failed"}});
Expand Down
18 changes: 18 additions & 0 deletions toolkits/lgraph_cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,24 @@ 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);
Expand Down

0 comments on commit f625d40

Please sign in to comment.