From fd21bed5aaa4a8ea8b768680720844e8b423fa0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Fri, 15 Mar 2019 20:35:17 +0200 Subject: [PATCH] Fix queued query handling If a routing of a queued query caused it to be put back on the query queue, the order in which the queue was reorganized was wrong. The first query would get appended as the last query which caused the order to be reversed. --- server/modules/routing/readwritesplit/readwritesplit.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/server/modules/routing/readwritesplit/readwritesplit.cc b/server/modules/routing/readwritesplit/readwritesplit.cc index 7dde02f89..82a37c38a 100644 --- a/server/modules/routing/readwritesplit/readwritesplit.cc +++ b/server/modules/routing/readwritesplit/readwritesplit.cc @@ -521,8 +521,10 @@ static bool route_stored_query(RWSplitSession *rses) } else { - /** Routing was stopped, we need to wait for a response before retrying */ - rses->query_queue = gwbuf_append(temp_storage, rses->query_queue); + /** Routing was stopped, we need to wait for a response before retrying. + * temp_storage holds the tail end of the queue and query_queue contains the query we attempted + * to route. Append temp_storage to query_queue to keep the order of the queries correct. */ + rses->query_queue = gwbuf_append(rses->query_queue, temp_storage); break; } }