Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy Andrew <mail@timothyandrew.net>2016-11-17 16:53:42 +0300
committerTimothy Andrew <mail@timothyandrew.net>2016-11-18 11:57:13 +0300
commitf95fa7145b41dbeb0cbaea1e9677fb7dd65a2f04 (patch)
treeb5defbfcfb4f849eb2ce1acee6f26547a4b55d98 /spec/support/database_connection_helpers.rb
parentbf9ab0f33d65df1566fcde8100576d23f5c77a4f (diff)
Write a spec covering the race condition during group deletion.
- Use multiple threads / database connections to: 1. Escape the transaction the spec seems to be running in (`config.use_transactional_fixtures` is off, but `ActiveRecord::Base.connection.open_transactions` is not empty at the beginning of the spec. 2. Simulate a Sidekiq worker performing the hard delete outside of the soft-delete transaction. - The spec is a little clunky, but it was the smallest thing I could get working - and even this took a couple of hours. Let me know if you have any suggestions to improve it!
Diffstat (limited to 'spec/support/database_connection_helpers.rb')
-rw-r--r--spec/support/database_connection_helpers.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/spec/support/database_connection_helpers.rb b/spec/support/database_connection_helpers.rb
new file mode 100644
index 00000000000..763329499f0
--- /dev/null
+++ b/spec/support/database_connection_helpers.rb
@@ -0,0 +1,9 @@
+module DatabaseConnectionHelpers
+ def run_with_new_database_connection
+ pool = ActiveRecord::Base.connection_pool
+ conn = pool.checkout
+ yield conn
+ ensure
+ pool.checkin(conn)
+ end
+end