Poorly behaved client fix (#65)

* Poorly behaved client fix

* yes officer

* fix tests

* no useless rescue

* Looks ok
This commit is contained in:
Lev Kokotov
2022-05-09 11:09:22 -05:00
committed by GitHub
parent df85139281
commit ccbca66e7a
4 changed files with 43 additions and 2 deletions

View File

@@ -1,6 +1,9 @@
# frozen_string_literal: true
require 'active_record'
require 'pg'
$stdout.sync = true
# Uncomment these two to see all queries.
# ActiveRecord.verbose_query_logs = true
@@ -110,3 +113,17 @@ begin
rescue ActiveRecord::StatementInvalid
puts 'OK'
end
# Test evil clients
def poorly_behaved_client
conn = PG::connect("postgres://sharding_user:sharding_user@127.0.0.1:6432/rails_dev")
conn.async_exec 'BEGIN'
conn.async_exec 'SELECT 1'
conn.close
puts 'Bad client ok'
end
25.times do
poorly_behaved_client
end