First try with role reset (#427)

* First try with role rest

* update

* extra line

* Update src/server.rs

Co-authored-by: Lev Kokotov <levkk@users.noreply.github.com>

* Update tests/ruby/misc_spec.rb

Co-authored-by: Lev Kokotov <levkk@users.noreply.github.com>

---------

Co-authored-by: Lev Kokotov <levkk@users.noreply.github.com>
This commit is contained in:
Andrew Tanner
2023-05-05 18:31:27 -04:00
committed by GitHub
parent 389993bf3e
commit 159eb89bf0
2 changed files with 13 additions and 0 deletions

View File

@@ -963,6 +963,7 @@ impl Server {
if self.needs_cleanup { if self.needs_cleanup {
warn!("Server returned with session state altered, discarding state"); warn!("Server returned with session state altered, discarding state");
self.query("DISCARD ALL").await?; self.query("DISCARD ALL").await?;
self.query("RESET ROLE").await?;
self.needs_cleanup = false; self.needs_cleanup = false;
} }

View File

@@ -241,6 +241,18 @@ describe "Miscellaneous" do
expect(processes.primary.count_query("DISCARD ALL")).to eq(10) expect(processes.primary.count_query("DISCARD ALL")).to eq(10)
end end
it "Resets server roles correctly" do
10.times do
conn = PG::connect(processes.pgcat.connection_string("sharded_db", "sharding_user"))
conn.async_exec("SET SERVER ROLE to 'primary'")
conn.async_exec("SELECT 1")
conn.async_exec("SET statement_timeout to 5000")
conn.close
end
expect(processes.primary.count_query("RESET ROLE")).to eq(10)
end
end end
context "transaction mode" do context "transaction mode" do