Added more debug output to tee filter.
This commit is contained in:
@ -63,6 +63,7 @@
|
|||||||
#include <mysql_client_server_protocol.h>
|
#include <mysql_client_server_protocol.h>
|
||||||
#include <housekeeper.h>
|
#include <housekeeper.h>
|
||||||
|
|
||||||
|
|
||||||
#define MYSQL_COM_QUIT 0x01
|
#define MYSQL_COM_QUIT 0x01
|
||||||
#define MYSQL_COM_INITDB 0x02
|
#define MYSQL_COM_INITDB 0x02
|
||||||
#define MYSQL_COM_FIELD_LIST 0x04
|
#define MYSQL_COM_FIELD_LIST 0x04
|
||||||
@ -78,6 +79,10 @@
|
|||||||
#define PARENT 0
|
#define PARENT 0
|
||||||
#define CHILD 1
|
#define CHILD 1
|
||||||
|
|
||||||
|
#ifdef SS_DEBUG
|
||||||
|
static int debug_seq = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
static unsigned char required_packets[] = {
|
static unsigned char required_packets[] = {
|
||||||
MYSQL_COM_QUIT,
|
MYSQL_COM_QUIT,
|
||||||
MYSQL_COM_INITDB,
|
MYSQL_COM_INITDB,
|
||||||
@ -171,6 +176,7 @@ typedef struct {
|
|||||||
GWBUF* tee_replybuf; /* Buffer for reply */
|
GWBUF* tee_replybuf; /* Buffer for reply */
|
||||||
GWBUF* tee_partials[2];
|
GWBUF* tee_partials[2];
|
||||||
SPINLOCK tee_lock;
|
SPINLOCK tee_lock;
|
||||||
|
DCB* client_dcb;
|
||||||
#ifdef SS_DEBUG
|
#ifdef SS_DEBUG
|
||||||
long d_id;
|
long d_id;
|
||||||
#endif
|
#endif
|
||||||
@ -328,7 +334,6 @@ void
|
|||||||
ModuleInit()
|
ModuleInit()
|
||||||
{
|
{
|
||||||
spinlock_init(&orphanLock);
|
spinlock_init(&orphanLock);
|
||||||
//hktask_add("tee orphan cleanup",orphan_free,NULL,15);
|
|
||||||
#ifdef SS_DEBUG
|
#ifdef SS_DEBUG
|
||||||
spinlock_init(&debug_lock);
|
spinlock_init(&debug_lock);
|
||||||
#endif
|
#endif
|
||||||
@ -493,6 +498,7 @@ char *remote, *userName;
|
|||||||
{
|
{
|
||||||
my_session->active = 1;
|
my_session->active = 1;
|
||||||
my_session->residual = 0;
|
my_session->residual = 0;
|
||||||
|
my_session->client_dcb = session->client;
|
||||||
spinlock_init(&my_session->tee_lock);
|
spinlock_init(&my_session->tee_lock);
|
||||||
if (my_instance->source &&
|
if (my_instance->source &&
|
||||||
(remote = session_get_remote(session)) != NULL)
|
(remote = session_get_remote(session)) != NULL)
|
||||||
@ -630,7 +636,9 @@ TEE_SESSION *my_session = (TEE_SESSION *)session;
|
|||||||
ROUTER_OBJECT *router;
|
ROUTER_OBJECT *router;
|
||||||
void *router_instance, *rsession;
|
void *router_instance, *rsession;
|
||||||
SESSION *bsession;
|
SESSION *bsession;
|
||||||
|
#ifdef SS_DEBUG
|
||||||
|
skygw_log_write(LOGFILE_TRACE,"Tee close: %d", atomic_add(&debug_seq,1));
|
||||||
|
#endif
|
||||||
if (my_session->active)
|
if (my_session->active)
|
||||||
{
|
{
|
||||||
if ((bsession = my_session->branch_session) != NULL)
|
if ((bsession = my_session->branch_session) != NULL)
|
||||||
@ -655,6 +663,16 @@ SESSION *bsession;
|
|||||||
* session.
|
* session.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
if(my_session->waiting[PARENT])
|
||||||
|
{
|
||||||
|
if(my_session->command != 0x01)
|
||||||
|
{
|
||||||
|
skygw_log_write(LOGFILE_TRACE,"Tee session closed mid-query.");
|
||||||
|
GWBUF* errbuf = modutil_create_mysql_err_msg(1,0,1,"00000","Session closed.");
|
||||||
|
my_session->client_dcb->func.write(my_session->client_dcb,errbuf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
my_session->active = 0;
|
my_session->active = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -671,6 +689,9 @@ freeSession(FILTER *instance, void *session)
|
|||||||
TEE_SESSION *my_session = (TEE_SESSION *)session;
|
TEE_SESSION *my_session = (TEE_SESSION *)session;
|
||||||
SESSION* ses = my_session->branch_session;
|
SESSION* ses = my_session->branch_session;
|
||||||
session_state_t state;
|
session_state_t state;
|
||||||
|
#ifdef SS_DEBUG
|
||||||
|
skygw_log_write(LOGFILE_TRACE,"Tee free: %d", atomic_add(&debug_seq,1));
|
||||||
|
#endif
|
||||||
if (ses != NULL)
|
if (ses != NULL)
|
||||||
{
|
{
|
||||||
state = ses->state;
|
state = ses->state;
|
||||||
@ -777,7 +798,11 @@ char *ptr;
|
|||||||
int length, rval, residual = 0;
|
int length, rval, residual = 0;
|
||||||
GWBUF *clone = NULL;
|
GWBUF *clone = NULL;
|
||||||
unsigned char command = *((unsigned char*)queue->start + 4);
|
unsigned char command = *((unsigned char*)queue->start + 4);
|
||||||
|
#ifdef SS_DEBUG
|
||||||
|
skygw_log_write(LOGFILE_TRACE,"Tee routeQuery: %d : %s",
|
||||||
|
atomic_add(&debug_seq,1),
|
||||||
|
((char*)queue->start + 5));
|
||||||
|
#endif
|
||||||
spinlock_acquire(&my_session->tee_lock);
|
spinlock_acquire(&my_session->tee_lock);
|
||||||
|
|
||||||
if(!my_session->active)
|
if(!my_session->active)
|
||||||
@ -864,7 +889,8 @@ if(!my_session->active)
|
|||||||
#endif
|
#endif
|
||||||
spinlock_acquire(&my_session->tee_lock);
|
spinlock_acquire(&my_session->tee_lock);
|
||||||
|
|
||||||
if(my_session->branch_session == NULL ||
|
if(!my_session->active ||
|
||||||
|
my_session->branch_session == NULL ||
|
||||||
my_session->branch_session->state != SESSION_STATE_ROUTER_READY)
|
my_session->branch_session->state != SESSION_STATE_ROUTER_READY)
|
||||||
{
|
{
|
||||||
rval = 0;
|
rval = 0;
|
||||||
@ -929,7 +955,14 @@ clientReply (FILTER* instance, void *session, GWBUF *reply)
|
|||||||
GWBUF *complete = NULL;
|
GWBUF *complete = NULL;
|
||||||
unsigned char *ptr;
|
unsigned char *ptr;
|
||||||
int min_eof = my_session->command != 0x04 ? 2 : 1;
|
int min_eof = my_session->command != 0x04 ? 2 : 1;
|
||||||
|
#ifdef SS_DEBUG
|
||||||
|
ptr = (unsigned char*) reply->start;
|
||||||
|
skygw_log_write(LOGFILE_TRACE,"Tee clientReply [%s] [%s] [%s]: %d",
|
||||||
|
instance ? "parent":"child",
|
||||||
|
my_session->active ? "open" : "closed",
|
||||||
|
PTR_IS_ERR(ptr) ? "ERR" : PTR_IS_OK(ptr) ? "OK" : "RSET",
|
||||||
|
atomic_add(&debug_seq,1));
|
||||||
|
#endif
|
||||||
spinlock_acquire(&my_session->tee_lock);
|
spinlock_acquire(&my_session->tee_lock);
|
||||||
|
|
||||||
if(!my_session->active)
|
if(!my_session->active)
|
||||||
@ -1007,8 +1040,8 @@ clientReply (FILTER* instance, void *session, GWBUF *reply)
|
|||||||
|
|
||||||
if(branch == PARENT)
|
if(branch == PARENT)
|
||||||
{
|
{
|
||||||
ss_dassert(my_session->tee_replybuf == NULL);
|
//ss_dassert(my_session->tee_replybuf == NULL);
|
||||||
my_session->tee_replybuf = complete;
|
my_session->tee_replybuf = gwbuf_append(my_session->tee_replybuf,complete);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user