Add verbose logging for session command failures

If the routing of a session command fails due to problems with the backend
connections, a more verbose error message is logged. The added status
information in the Backend class makes tracking the original cause of the
problem a lot easier due to knowing where, when and why the connection was
closed.
This commit is contained in:
Markus Mäkelä
2019-01-28 10:56:01 +02:00
parent df9335382d
commit 24c9b62a2f
5 changed files with 116 additions and 2 deletions

View File

@ -330,6 +330,23 @@ public:
int64_t num_selects() const;
const maxbase::StopWatch& session_timer() const;
const maxbase::IntervalTimer& select_timer() const;
/**
* Get verbose status description
*
* @return A verbose description of the backend's status
*/
std::string get_verbose_status() const;
/**
* Add explanation message to latest close reason
*
* The message is printed in get_verbose_status() if the backend is closed.
*
* @param reason The human-readable message
*/
void set_close_reason(const std::string& reason);
private:
/**
* Internal state of the backend
@ -355,8 +372,13 @@ private:
*/
void set_state(backend_state state);
// Stringification function
static std::string to_string(backend_state state);
bool m_closed; /**< True if a connection has been opened and closed */
time_t m_closed_at; /**< Timestamp when the backend was last closed */
std::string m_close_reason; /**< Why the backend was closed */
time_t m_opened_at; /**< Timestamp when the backend was last opened */
SERVER_REF* m_backend; /**< Backend server */
DCB* m_dcb; /**< Backend DCB */
mxs::Buffer m_pending_cmd; /**< Pending commands */