diff --git a/server/core/queryclassifier.cc b/server/core/queryclassifier.cc index 802a2fe5f..18d87d929 100644 --- a/server/core/queryclassifier.cc +++ b/server/core/queryclassifier.cc @@ -390,8 +390,18 @@ uint32_t QueryClassifier::ps_get_type(std::string id) const void QueryClassifier::ps_erase(GWBUF* buffer) { - m_ps_handles.erase(qc_mysql_extract_ps_id(buffer)); - m_sPs_manager->erase(buffer); + if (qc_mysql_is_ps_command(mxs_mysql_get_command(buffer))) + { + // Erase the type of the statement stored with the internal ID + m_sPs_manager->erase(ps_id_internal_get(buffer)); + // ... and then erase the external to internal ID mapping + m_ps_handles.erase(qc_mysql_extract_ps_id(buffer)); + } + else + { + // Not a PS command, we don't need the ID mapping + m_sPs_manager->erase(buffer); + } } bool QueryClassifier::query_type_is_read_only(uint32_t qtype) const diff --git a/server/modules/routing/readwritesplit/rwsplit_route_stmt.cc b/server/modules/routing/readwritesplit/rwsplit_route_stmt.cc index 65cf6092f..56fc1c2fb 100644 --- a/server/modules/routing/readwritesplit/rwsplit_route_stmt.cc +++ b/server/modules/routing/readwritesplit/rwsplit_route_stmt.cc @@ -451,6 +451,7 @@ bool RWSplitSession::route_session_write(GWBUF* querybuf, uint8_t command, uint3 } else if (qc_query_is_type(type, QUERY_TYPE_DEALLOC_PREPARE)) { + mxb_assert(!mxs_mysql_is_ps_command(m_qc.current_route_info().command())); m_qc.ps_erase(querybuf); }