diff options
author | Thong Kuah <tkuah@gitlab.com> | 2018-12-14 10:38:03 +1300 |
---|---|---|
committer | Thong Kuah <tkuah@gitlab.com> | 2019-03-05 10:31:33 +1300 |
commit | be99adb1498420be74d05d3e328632b24b5725a6 (patch) | |
tree | 0322be7578bf9572bcd5ac615ea64dc19109af68 | |
parent | 56d4ef8d221825e0d39b53bd4e427580f8782f84 (diff) | |
download | gitlab-ce-be99adb1498420be74d05d3e328632b24b5725a6.tar.gz |
Show pg_stat_activity before each test run
Maybe this will help us debug
https://gitlab.com/gitlab-org/gitlab-ee/issues/10154
-rw-r--r-- | spec/support/pg_stat_activity.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/spec/support/pg_stat_activity.rb b/spec/support/pg_stat_activity.rb new file mode 100644 index 00000000000..f93fba08a19 --- /dev/null +++ b/spec/support/pg_stat_activity.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +RSpec.configure do |config| + config.before do + if Gitlab::Database.postgresql? && ENV['PG_STAT_WARNING_THRESHOLD'] + warning_threshold = ENV['PG_STAT_WARNING_THRESHOLD'].to_i + results = ActiveRecord::Base.connection.execute('SELECT * FROM pg_stat_activity') + ntuples = results.ntuples + + warn("pg_stat_activity count: #{ntuples}") + + if ntuples > warning_threshold + results.each do |result| + warn result.inspect + end + end + end + end +end |