Backported the changes that convert the query queue in readwritesplit into a proper queue. This changes combines both 5e3198f8313b7bb33df386eb35986bfae1db94a3 and 6042a53cb31046b1100743723567906c5d8208e2 into one commit.