MXS-1780 Collect server response information
As the router is the only one that knows what backends a particular statement has been sent to, it is the responsibility of the router to keep the session bookkeeping up to date. If it doesn't we will know what statements a session has received (provided at least some component in the routing chain has RCAP_TYPE_STMT_INPUT capability), but not how long their processing took. Currently only readwritesplit does that. All queries are stored and not just COM_QUERY as that makes the overall bookkeeping simpler; at clientReply() time we do not need to know whether or not to bookkeep information, we can just do it. When session information is queried for, we report as much information we have available.
This commit is contained in:
@ -61,24 +61,42 @@ public:
|
||||
class Session : public MXS_SESSION
|
||||
{
|
||||
public:
|
||||
class StatementInfo
|
||||
class QueryInfo
|
||||
{
|
||||
public:
|
||||
StatementInfo(const std::shared_ptr<GWBUF>& sStatement);
|
||||
QueryInfo(const std::shared_ptr<GWBUF>& sQuery);
|
||||
|
||||
json_t* as_json() const;
|
||||
|
||||
const std::shared_ptr<GWBUF>& statement() const
|
||||
bool complete() const
|
||||
{
|
||||
return m_sStatement;
|
||||
return m_complete;
|
||||
}
|
||||
|
||||
const std::shared_ptr<GWBUF>& query() const
|
||||
{
|
||||
return m_sQuery;
|
||||
}
|
||||
|
||||
void book_server_response(SERVER* pServer, bool final_response);
|
||||
void book_as_complete();
|
||||
void reset_server_bookkeeping();
|
||||
|
||||
struct ServerInfo
|
||||
{
|
||||
SERVER* pServer;
|
||||
timespec processed;
|
||||
};
|
||||
|
||||
private:
|
||||
std::shared_ptr<GWBUF> m_sStatement;
|
||||
timespec m_received;
|
||||
std::shared_ptr<GWBUF> m_sQuery; /*< The packet, COM_QUERY *or* something else. */
|
||||
timespec m_received; /*< When was it received. */
|
||||
timespec m_completed; /*< When was it completed. */
|
||||
std::vector<ServerInfo> m_server_infos; /*< When different servers responded. */
|
||||
bool m_complete = false; /*< Is this information complete? */
|
||||
};
|
||||
|
||||
typedef std::deque<StatementInfo> SessionStmtQueue;
|
||||
typedef std::deque<QueryInfo> QueryInfos;
|
||||
|
||||
using FilterList = std::vector<SessionFilter>;
|
||||
|
||||
@ -99,8 +117,11 @@ public:
|
||||
bool remove_variable(const char* name, void** context);
|
||||
void retain_statement(GWBUF* pBuffer);
|
||||
void dump_statements() const;
|
||||
void book_server_response(SERVER* pServer, bool final_response);
|
||||
void book_last_as_complete();
|
||||
void reset_server_bookkeeping();
|
||||
|
||||
json_t* statements_as_json() const;
|
||||
json_t* queries_as_json() const;
|
||||
|
||||
void link_backend_dcb(DCB* dcb)
|
||||
{
|
||||
@ -122,8 +143,9 @@ public:
|
||||
private:
|
||||
FilterList m_filters;
|
||||
SessionVarsByName m_variables;
|
||||
SessionStmtQueue m_last_statements;/*< The N last statements by the client */
|
||||
DCBSet m_dcb_set; /*< Set of associated backend DCBs */
|
||||
QueryInfos m_last_queries; /*< The N last queries by the client */
|
||||
int m_current_query = -1; /*< The index of the current query */
|
||||
DCBSet m_dcb_set; /*< Set of associated backend DCBs */
|
||||
};
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user