Commit 2b4e0ec8 authored by Thong Kuah's avatar Thong Kuah Committed by Adam Hegyi

Fix connection search path being reset

RESET ALL is reseting too many parameters, we should reset only the
parameter we just set, namely statement_timeout

https://gitlab.com/gitlab-org/gitlab/-/issues/337813

Changelog: fixed
parent d323d728
......@@ -341,9 +341,9 @@ module Gitlab
# - Per connection (requires a cleanup after the execution)
#
# When using a per connection disable statement, code must be inside
# a block so we can automatically execute `RESET ALL` after block finishes
# a block so we can automatically execute `RESET statement_timeout` after block finishes
# otherwise the statement will still be disabled until connection is dropped
# or `RESET ALL` is executed
# or `RESET statement_timeout` is executed
def disable_statement_timeout
if block_given?
if statement_timeout_disabled?
......@@ -357,7 +357,7 @@ module Gitlab
yield
ensure
execute('RESET ALL')
execute('RESET statement_timeout')
end
end
else
......
......@@ -14,10 +14,10 @@ RSpec.shared_examples 'performs validation' do |validation_option|
it 'performs validation' do
expect(model).to receive(:disable_statement_timeout).and_call_original
expect(model).to receive(:statement_timeout_disabled?).and_return(false)
expect(model).to receive(:execute).with(/statement_timeout/)
expect(model).to receive(:execute).with(/SET statement_timeout TO/)
expect(model).to receive(:execute).ordered.with(/NOT VALID/)
expect(model).to receive(:execute).ordered.with(/VALIDATE CONSTRAINT/)
expect(model).to receive(:execute).ordered.with(/RESET ALL/)
expect(model).to receive(:execute).ordered.with(/RESET statement_timeout/)
model.add_concurrent_foreign_key(*args, **options.merge(validation_option))
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment