File tree Expand file tree Collapse file tree 4 files changed +43
-2
lines changed Expand file tree Collapse file tree 4 files changed +43
-2
lines changed Original file line number Diff line number Diff line change @@ -359,7 +359,8 @@ impl Client {
359359 // Clean up the server and re-use it.
360360 // This prevents connection thrashing by bad clients.
361361 if server. in_transaction ( ) {
362- server. query ( "ROLLBACK; DISCARD ALL;" ) . await ?;
362+ server. query ( "ROLLBACK" ) . await ?;
363+ server. query ( "DISCARD ALL" ) . await ?;
363364 }
364365
365366 return Err ( err) ;
@@ -429,7 +430,8 @@ impl Client {
429430 // Pgbouncer closes the connection which leads to
430431 // connection thrashing when clients misbehave.
431432 if server. in_transaction ( ) {
432- server. query ( "ROLLBACK; DISCARD ALL;" ) . await ?;
433+ server. query ( "ROLLBACK" ) . await ?;
434+ server. query ( "DISCARD ALL" ) . await ?;
433435 }
434436
435437 return Ok ( ( ) ) ;
Original file line number Diff line number Diff line change @@ -2,3 +2,4 @@ source "https://rubygems.org"
22
33gem "pg"
44gem "activerecord"
5+ gem "rubocop"
Original file line number Diff line number Diff line change 1111 i18n (>= 1.6 , < 2 )
1212 minitest (>= 5.1 )
1313 tzinfo (~> 2.0 )
14+ ast (2.4.2 )
1415 concurrent-ruby (1.1.9 )
1516 i18n (1.10.0 )
1617 concurrent-ruby (~> 1.0 )
1718 minitest (5.15.0 )
19+ parallel (1.22.1 )
20+ parser (3.1.2.0 )
21+ ast (~> 2.4.1 )
1822 pg (1.3.2 )
23+ rainbow (3.1.1 )
24+ regexp_parser (2.3.1 )
25+ rexml (3.2.5 )
26+ rubocop (1.29.0 )
27+ parallel (~> 1.10 )
28+ parser (>= 3.1.0.0 )
29+ rainbow (>= 2.2.2 , < 4.0 )
30+ regexp_parser (>= 1.8 , < 3.0 )
31+ rexml (>= 3.2.5 , < 4.0 )
32+ rubocop-ast (>= 1.17.0 , < 2.0 )
33+ ruby-progressbar (~> 1.7 )
34+ unicode-display_width (>= 1.4.0 , < 3.0 )
35+ rubocop-ast (1.17.0 )
36+ parser (>= 3.1.1.0 )
37+ ruby-progressbar (1.11.0 )
1938 tzinfo (2.0.4 )
2039 concurrent-ruby (~> 1.0 )
40+ unicode-display_width (2.1.0 )
2141
2242PLATFORMS
2343 x86_64-linux
2444
2545DEPENDENCIES
2646 activerecord
2747 pg
48+ rubocop
2849
2950BUNDLED WITH
3051 2.3.7
Original file line number Diff line number Diff line change 11# frozen_string_literal: true
22
33require 'active_record'
4+ require 'pg'
5+
6+ $stdout. sync = true
47
58# Uncomment these two to see all queries.
69# ActiveRecord.verbose_query_logs = true
@@ -110,3 +113,17 @@ def down
110113rescue ActiveRecord ::StatementInvalid
111114 puts 'OK'
112115end
116+
117+ # Test evil clients
118+ def poorly_behaved_client
119+ conn = PG ::
connect ( "postgres://sharding_user:[email protected] :6432/rails_dev" ) 120+ conn . async_exec 'BEGIN'
121+ conn . async_exec 'SELECT 1'
122+
123+ conn . close
124+ puts 'Bad client ok'
125+ end
126+
127+ 25 . times do
128+ poorly_behaved_client
129+ end
You can’t perform that action at this time.
0 commit comments