MXS-1734 Add statement dumping mechanism
With the configuration entry
retain_last_statements=<unsigned>
or the debug flag '--debug=retain-last-statements=<unsigned>',
MaxScale will store the specified number of last statements
for each session. By calling
session_dump_statements(session);
MaxScale will dump the last statements as NOTICE messages.
For debugging purposes.
This commit is contained in:
@ -142,6 +142,7 @@ extern const char CN_QUERY_RETRY_TIMEOUT[];
|
||||
extern const char CN_RELATIONSHIPS[];
|
||||
extern const char CN_LINKS[];
|
||||
extern const char CN_REQUIRED[];
|
||||
extern const char CN_RETAIN_LAST_STATEMENTS[];
|
||||
extern const char CN_RETRY_ON_FAILURE[];
|
||||
extern const char CN_ROUTER[];
|
||||
extern const char CN_ROUTER_DIAGNOSTICS[];
|
||||
|
||||
@ -27,6 +27,14 @@
|
||||
#include <maxscale/spinlock.h>
|
||||
#include <maxscale/jansson.h>
|
||||
|
||||
#if defined(__cplusplus)
|
||||
#include <deque>
|
||||
#include <vector>
|
||||
typedef std::deque<std::vector<uint8_t> > SessionStmtQueue;
|
||||
#else
|
||||
typedef void SessionStmtQueue;
|
||||
#endif
|
||||
|
||||
MXS_BEGIN_DECLS
|
||||
|
||||
struct dcb;
|
||||
@ -153,6 +161,7 @@ typedef struct session
|
||||
const struct server *target; /**< Where the statement was sent */
|
||||
} stmt; /**< Current statement being executed */
|
||||
bool qualifies_for_pooling; /**< Whether this session qualifies for the connection pool */
|
||||
SessionStmtQueue* last_statements; /*< The N last statements by the client */
|
||||
skygw_chk_t ses_chk_tail;
|
||||
} MXS_SESSION;
|
||||
|
||||
@ -481,4 +490,27 @@ MXS_SESSION* session_get_current();
|
||||
**/
|
||||
uint64_t session_get_current_id();
|
||||
|
||||
/**
|
||||
* @brief Specify how many statements each session should retain for
|
||||
* debugging purposes.
|
||||
*
|
||||
* @param n The number of statements.
|
||||
*/
|
||||
void session_retain_last_statements(uint32_t n);
|
||||
|
||||
/**
|
||||
* @brief Retain provided statement, if configured to do so.
|
||||
*
|
||||
* @param session The session.
|
||||
* @param buffer Buffer assumed to contain a full statement.
|
||||
*/
|
||||
void session_retain_statement(MXS_SESSION* session, GWBUF* buffer);
|
||||
|
||||
/**
|
||||
* @brief Dump the last statements, if statements have been retained.
|
||||
*
|
||||
* @param session The session.
|
||||
*/
|
||||
void session_dump_statements(MXS_SESSION* pSession);
|
||||
|
||||
MXS_END_DECLS
|
||||
|
||||
Reference in New Issue
Block a user