From 5c500ca1decc8240b0b0986cda7e207a6e0990fb Mon Sep 17 00:00:00 2001 From: songqing Date: Mon, 4 Sep 2023 17:16:11 +0800 Subject: [PATCH] fix session error --- include/nebula/client/Session.h | 6 ++++++ src/client/Session.cpp | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/nebula/client/Session.h b/include/nebula/client/Session.h index 426f72ce..c8f9fbb4 100644 --- a/include/nebula/client/Session.h +++ b/include/nebula/client/Session.h @@ -110,6 +110,12 @@ class Session { return toLocal(data, offsetSecs_); } + bool isSessionError(const ExecutionResponse &resp) { + return resp.errorCode == ErrorCode::E_SESSION_INVALID || + resp.errorCode == ErrorCode::E_SESSION_NOT_FOUND || + resp.errorCode == ErrorCode::E_SESSION_TIMEOUT; + } + // convert the time to specific time zone static void toLocal(DataSet &data, int32_t offsetSecs); diff --git a/src/client/Session.cpp b/src/client/Session.cpp index d1473dc9..3dc0f354 100644 --- a/src/client/Session.cpp +++ b/src/client/Session.cpp @@ -37,7 +37,7 @@ ExecutionResponse Session::executeWithParameter( auto resp = conn_.executeWithParameter(sessionId_, stmt, parameters); if (resp.errorCode == nebula::ErrorCode::SUCCEEDED) { return resp; - } else if (resp.errorCode == nebula::ErrorCode::E_FAIL_TO_CONNECT) { + } else if (resp.errorCode == nebula::ErrorCode::E_FAIL_TO_CONNECT || isSessionError(resp)) { connectionIsBroken_ = true; if (retryConnect_) { if (retryConnect() == nebula::ErrorCode::SUCCEEDED) {