MXS-2295: Keep the COM_CHANGE_USER command
If the whole session command history is cleared, the COM_CHANGE_USER is lost and the connections can end up using different users.
This commit is contained in:
		@ -165,14 +165,28 @@ void RWSplitSession::process_sescmd_response(SRWBackend& backend, GWBUF** ppPack
 | 
			
		||||
        if (m_expected_responses == 0
 | 
			
		||||
            && (command == MXS_COM_CHANGE_USER || command == MXS_COM_RESET_CONNECTION))
 | 
			
		||||
        {
 | 
			
		||||
            mxb_assert_message(m_slave_responses.empty(), "All responses should've been processed");
 | 
			
		||||
            // This is the last session command to finish that resets the session state, reset the history
 | 
			
		||||
            MXS_INFO("Resetting session command history (length: %lu)", m_sescmd_list.size());
 | 
			
		||||
 | 
			
		||||
            /**
 | 
			
		||||
             * Since new connections need to perform the COM_CHANGE_USER, pop it off the list along
 | 
			
		||||
             * with the expected response to it.
 | 
			
		||||
             */
 | 
			
		||||
            SSessionCommand latest = m_sescmd_list.back();
 | 
			
		||||
            cmd = m_sescmd_responses[latest->get_position()];
 | 
			
		||||
 | 
			
		||||
            m_sescmd_list.clear();
 | 
			
		||||
            m_sescmd_responses.clear();
 | 
			
		||||
            m_slave_responses.clear();
 | 
			
		||||
            m_recv_sescmd = 0;
 | 
			
		||||
            m_sent_sescmd = 0;
 | 
			
		||||
            m_sescmd_count = 1;
 | 
			
		||||
 | 
			
		||||
            // Push the response back as the first executed session command
 | 
			
		||||
            m_sescmd_list.push_back(latest);
 | 
			
		||||
            m_sescmd_responses[latest->get_position()] = cmd;
 | 
			
		||||
 | 
			
		||||
            // Adjust counters to match the number of stored session commands
 | 
			
		||||
            m_recv_sescmd = 1;
 | 
			
		||||
            m_sent_sescmd = 1;
 | 
			
		||||
            m_sescmd_count = 2;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -139,7 +139,7 @@ public:
 | 
			
		||||
    int                 m_last_keepalive_check; /**< When the last ping was done */
 | 
			
		||||
    int                 m_nbackends;            /**< Number of backend servers (obsolete) */
 | 
			
		||||
    DCB*                m_client;               /**< The client DCB */
 | 
			
		||||
    uint64_t            m_sescmd_count;         /**< Number of executed session commands */
 | 
			
		||||
    uint64_t            m_sescmd_count;         /**< Number of executed session commands (starts from 1) */
 | 
			
		||||
    int                 m_expected_responses;   /**< Number of expected responses to the current
 | 
			
		||||
                                                 * query */
 | 
			
		||||
    GWBUF*                  m_query_queue;      /**< Queued commands waiting to be executed */
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user