add synchronization to SqlQuery.GetQueryRules/SetQueryRules to avoid race condition