Skip to content

Commit 159eb89

Browse files
atanner27levkk
andauthored
First try with role reset (#427)
* First try with role rest * update * extra line * Update src/server.rs Co-authored-by: Lev Kokotov <[email protected]> * Update tests/ruby/misc_spec.rb Co-authored-by: Lev Kokotov <[email protected]> --------- Co-authored-by: Lev Kokotov <[email protected]>
1 parent 389993b commit 159eb89

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/server.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -963,6 +963,7 @@ impl Server {
963963
if self.needs_cleanup {
964964
warn!("Server returned with session state altered, discarding state");
965965
self.query("DISCARD ALL").await?;
966+
self.query("RESET ROLE").await?;
966967
self.needs_cleanup = false;
967968
}
968969

tests/ruby/misc_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,18 @@
241241

242242
expect(processes.primary.count_query("DISCARD ALL")).to eq(10)
243243
end
244+
245+
it "Resets server roles correctly" do
246+
10.times do
247+
conn = PG::connect(processes.pgcat.connection_string("sharded_db", "sharding_user"))
248+
conn.async_exec("SET SERVER ROLE to 'primary'")
249+
conn.async_exec("SELECT 1")
250+
conn.async_exec("SET statement_timeout to 5000")
251+
conn.close
252+
end
253+
254+
expect(processes.primary.count_query("RESET ROLE")).to eq(10)
255+
end
244256
end
245257

246258
context "transaction mode" do

0 commit comments

Comments
 (0)