Comments (8)
@bellebaum I should have written you, but the messages in your log kind of message type 0x31 arrived from server while idle
are a pretty safe sign of running multiple threads at the same time on a single connection. I'll ask the PostgreSQL people if we can make this message a bit more descriptive.
from ruby-pg.
@larskanis Thank you :)
Judging by the comments, this seems to be a common misconception, to think that this gem could be used in rails, sinatra, etc. without any wrapper.
Maybe we should add a warning in the README to use something like the connection pool gem when accessing this gem from multiple threads.
One could, of course, also just add proper locks to this gem, but I think this would be overkill. Still, as it stands, the internal ruby backtraces are quite scary and without any warnings it is hard to distinguish actual bugs from misuse of this gem. Keep in mind that many Ruby programmers are not C programmers, and so finding the right documentation (probably the C pg client docs) may be hard for them.
from ruby-pg.
I experienced this mystery crash with pg
when using Tapioca to generate RBI files, and nothing seemed to fix it apart from reverting to 1.3.0, excepting this helpful note suggesting setting this environment variable:
export PGGSSENCMODE="disable"
Which for me resolves the issue.
None of the versions between 1.3.1 and 1.5.4 worked without this variable set, at least on Ruby 3.2.2 (macOS ARM).
from ruby-pg.
Hello.
The same error occurred to me and I am getting a core dumped error.
I couldn't solve this error (or whatever) can you help me ?
ruby 3.0.1
rails 6.1.7
pg 1.4.5
Error:
logs.txt
from ruby-pg.
The same Issue for me
-- Control frame information -----------------------------------------------
c:0064 p:---- s:0369 e:000368 CFUNC :connect_poll
c:0063 p:0543 s:0365 e:000364 METHOD .../.rvm/gems/ruby-3.0.0/gems/pg-1.4.4/lib/pg/connection.rb:626
c:0062 p:0341 s:0352 e:000351 METHOD .../.rvm/gems/ruby-3.0.0/gems/pg-1.4.4/lib/pg/connection.rb:759
c:0061 p:0007 s:0341 e:000340 METHOD .../.rvm/gems/ruby-3.0.0/gems/pg-1.4.4/lib/pg/connection.rb:695
c:0060 p:0019 s:0335 e:000334 METHOD .../.rvm/gems/ruby-3.0.0/gems/pg-1.4.4/lib/pg.rb:69
c:0059 p:0013 s:0329 e:000328 METHOD .../.rvm/gems/ruby-3.0.0/gems/activerecord-6.1.7.2/lib/active_record/connection_adapters/postgresql_adapter.rb:78
c:0058 p:0112 s:0323 e:000321 METHOD .../.rvm/gems/ruby-3.0.0/gems/activerecord-6.1.7.2/lib/active_record/connection_adapters/postgresql_adapter.rb:37 [FINISH]
c:0057 p:---- s:0315 e:000314 CFUNC :public_send
c:0056 p:0021 s:0309 e:000308 METHOD .../.rvm/gems/ruby-3.0.0/gems/activerecord-6.1.7.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:882
c:0055 p:0021 s:0305 e:000304 METHOD .../.rvm/gems/ruby-3.0.0/gems/activerecord-6.1.7.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:926
c:0054 p:0014 s:0301 e:000300 METHOD .../.rvm/gems/ruby-3.0.0/gems/activerecord-6.1.7.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:905
c:0053 p:0012 s:0295 e:000294 METHOD .../.rvm/gems/ruby-3.0.0/gems/activerecord-6.1.7.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:866
c:0052 p:0011 s:0289 e:000287 METHOD .../.rvm/gems/ruby-3.0.0/gems/activerecord-6.1.7.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:588
c:0051 p:0021 s:0283 e:000279 METHOD .../.rvm/gems/ruby-3.0.0/gems/activerecord-6.1.7.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:428
c:0050 p:0291 s:0276 e:000275 METHOD .../.rvm/gems/ruby-3.0.0/gems/activerecord-6.1.7.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:112
c:0049 p:0014 s:0266 e:000265 METHOD .../.rvm/gems/ruby-3.0.0/gems/activerecord-6.1.7.2/lib/active_record/connection_handling.rb:327
c:0048 p:0003 s:0262 e:000261 METHOD .../.rvm/gems/ruby-3.0.0/gems/activerecord-6.1.7.2/lib/active_record/connection_handling.rb:283
c:0047 p:0027 s:0258 e:000257 METHOD .../.rvm/gems/ruby-3.0.0/gems/activerecord-6.1.7.2/lib/active_record/tasks/postgresql_database_tasks.rb:12
c:0046 p:0015 s:0250 e:000249 METHOD .../.rvm/gems/ruby-3.0.0/gems/activerecord-6.1.7.2/lib/active_record/tasks/postgresql_database_tasks.rb:26
c:0045 p:0018 s:0245 e:000244 METHOD .../.rvm/gems/ruby-3.0.0/gems/activerecord-6.1.7.2/lib/active_record/tasks/database_tasks.rb:133
c:0044 p:0006 s:0237 e:000236 BLOCK .../.rvm/gems/ruby-3.0.0/gems/activerecord-6.1.7.2/lib/active_record/tasks/database_tasks.rb:193
c:0043 p:0024 s:0233 e:000232 BLOCK .../.rvm/gems/ruby-3.0.0/gems/activerecord-6.1.7.2/lib/active_record/tasks/database_tasks.rb:506 [FINISH]
c:0042 p:---- s:0229 e:000228 CFUNC :each
c:0041 p:0023 s:0225 e:000224 BLOCK .../.rvm/gems/ruby-3.0.0/gems/activerecord-6.1.7.2/lib/active_record/tasks/database_tasks.rb:503 [FINISH]
c:0040 p:---- s:0221 e:000220 CFUNC :each
c:0039 p:0063 s:0217 e:000216 METHOD .../.rvm/gems/ruby-3.0.0/gems/activerecord-6.1.7.2/lib/active_record/tasks/database_tasks.rb:502
c:0038 p:0016 s:0210 e:000209 METHOD .../.rvm/gems/ruby-3.0.0/gems/activerecord-6.1.7.2/lib/active_record/tasks/database_tasks.rb:193
c:0037 p:0020 s:0204 e:000203 BLOCK .../.rvm/gems/ruby-3.0.0/gems/activerecord-6.1.7.2/lib/active_record/railties/databases.rake:45
c:0036 p:0008 s:0201 e:000200 BLOCK .../.rvm/gems/ruby-3.0.0/gems/rake-13.0.6/lib/rake/task.rb:281 [FINISH]
c:0035 p:---- s:0197 e:000196 CFUNC :each
c:0034 p:0142 s:0193 e:000192 METHOD .../.rvm/gems/ruby-3.0.0/gems/rake-13.0.6/lib/rake/task.rb:281
c:0033 p:0137 s:0187 E:000268 BLOCK .../.rvm/gems/ruby-3.0.0/gems/rake-13.0.6/lib/rake/task.rb:219 [FINISH]
c:0032 p:---- s:0183 e:000182 CFUNC :synchronize
c:0031 p:0026 s:0179 E:000238 METHOD .../.rvm/gems/ruby-3.0.0/gems/rake-13.0.6/lib/rake/task.rb:199
c:0030 p:0036 s:0172 E:0002a0 METHOD .../.rvm/gems/ruby-3.0.0/gems/rake-13.0.6/lib/rake/task.rb:188
c:0029 p:0027 s:0166 E:0002d0 METHOD .../.rvm/gems/ruby-3.0.0/gems/rake-13.0.6/lib/rake/application.rb:160
c:0028 p:0006 s:0158 E:000338 BLOCK .../.rvm/gems/ruby-3.0.0/gems/rake-13.0.6/lib/rake/application.rb:116 [FINISH]
c:0027 p:---- s:0154 e:000153 CFUNC :each
c:0026 p:0029 s:0150 E:000300 BLOCK .../.rvm/gems/ruby-3.0.0/gems/rake-13.0.6/lib/rake/application.rb:116
c:0025 p:0019 s:0147 E:000398 METHOD .../.rvm/gems/ruby-3.0.0/gems/rake-13.0.6/lib/rake/application.rb:125
c:0024 p:0004 s:0142 E:0002d0 METHOD .../.rvm/gems/ruby-3.0.0/gems/rake-13.0.6/lib/rake/application.rb:110
c:0023 p:0005 s:0138 E:000430 BLOCK .../.rvm/gems/ruby-3.0.0/gems/railties-6.1.7.2/lib/rails/commands/rake/rake_command.rb:24
c:0022 p:0002 s:0135 E:000498 METHOD .../.rvm/gems/ruby-3.0.0/gems/rake-13.0.6/lib/rake/application.rb:186
c:0021 p:0087 s:0130 E:000408 BLOCK .../.rvm/gems/ruby-3.0.0/gems/railties-6.1.7.2/lib/rails/commands/rake/rake_command.rb:24
c:0020 p:0048 s:0126 E:000500 METHOD .../.rvm/gems/ruby-3.0.0/gems/rake-13.0.6/lib/rake/rake_module.rb:59
c:0019 p:0016 s:0120 E:0003d8 METHOD .../.rvm/gems/ruby-3.0.0/gems/railties-6.1.7.2/lib/rails/commands/rake/rake_command.rb:18
c:0018 p:0164 s:0113 E:000570 METHOD .../.rvm/gems/ruby-3.0.0/gems/railties-6.1.7.2/lib/rails/command.rb:50
c:0017 p:0063 s:0101 E:0005b0 TOP .../.rvm/gems/ruby-3.0.0/gems/railties-6.1.7.2/lib/rails/commands.rb:18 [FINISH]
c:0016 p:---- s:0096 e:000095 CFUNC :require
c:0015 p:0258 s:0091 E:000610 METHOD .../.rvm/gems/ruby-3.0.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32
c:0014 p:0051 s:0081 E:000648 TOP .../bin/rails:9 [FINISH]
c:0013 p:---- s:0077 e:000076 CFUNC :load
c:0012 p:0130 s:0072 E:000678 METHOD .../.rvm/gems/ruby-3.0.0/gems/spring-2.1.1/lib/spring/client/rails.rb:28
c:0011 p:0007 s:0067 E:0006a8 METHOD .../.rvm/gems/ruby-3.0.0/gems/spring-2.1.1/lib/spring/client/command.rb:7
c:0010 p:0011 s:0062 E:0006e0 METHOD .../.rvm/gems/ruby-3.0.0/gems/spring-2.1.1/lib/spring/client.rb:30
c:0009 p:0302 s:0056 E:000728 TOP .../.rvm/gems/ruby-3.0.0/gems/spring-2.1.1/bin/spring:49 [FINISH]
c:0008 p:---- s:0050 e:000049 CFUNC :load
c:0007 p:0114 s:0045 E:000768 TOP .../.rvm/gems/ruby-3.0.0/gems/spring-2.1.1/lib/spring/binstub.rb:11 [FINISH]
c:0006 p:---- s:0039 e:000038 CFUNC :require
c:0005 p:0195 s:0034 E:001d28 METHOD <internal:.../.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85
c:0004 p:0129 s:0017 E:0007a0 TOP .../bin/spring:15 [FINISH]
c:0003 p:---- s:0012 e:000011 CFUNC :load
c:0002 p:0018 s:0007 E:000fe8 EVAL bin/rails:3 [FINISH]
c:0001 p:0000 s:0003 E:000510 (none) [FINISH]
from ruby-pg.
the same issue with 1.4.2 v when trying to connect remote db. Ruby: 3.0.0, Rails 7, Ubuntu 22.04, openssl 3
from ruby-pg.
For me, the issue turned out to be missing thread safety in this gem. Maybe a warning should help?
from ruby-pg.
Running Ubuntu 22.04
Ruby 2.7.1
Rails 5.2.6
Take a look at this command ran on the rails console
[2] pry(main)> PG::Connection.new(host: 'myhost', user: 'postgres', password: '123', dbname: 'mydb')
(pry):2: [BUG] Segmentation fault at 0x00007f046937d140
ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-linux]
-- Control frame information -----------------------------------------------
c:0036 p:---- s:0203 e:000202 CFUNC :initialize
c:0035 p:---- s:0200 e:000199 CFUNC :new
c:0034 p:0023 s:0195 e:000194 EVAL (pry):2 [FINISH]
c:0033 p:---- s:0192 e:000191 CFUNC :eval
c:0032 p:0042 s:0185 e:000184 METHOD /home/mypersonalfolder/.rvm/gems/ruby-2.7.1/gems/pry-0.14.1/lib/pry/pry_instance.rb:290
c:0031 p:0240 s:0179 e:000178 METHOD /home/mypersonalfolder/.rvm/gems/ruby-2.7.1/gems/pry-0.14.1/lib/pry/pry_instance.rb:659
c:0030 p:0010 s:0168 e:000167 BLOCK /home/mypersonalfolder/.rvm/gems/ruby-2.7.1/gems/pry-0.14.1/lib/pry/pry_instance.rb:261 [FINISH]
c:0029 p:---- s:0165 e:000164 CFUNC :catch
c:0028 p:0007 s:0160 e:000159 BLOCK /home/mypersonalfolder/.rvm/gems/ruby-2.7.1/gems/pry-0.14.1/lib/pry/pry_instance.rb:260 [FINISH]
c:0027 p:---- s:0157 e:000156 CFUNC :catch
c:0026 p:0021 s:0152 e:000151 METHOD /home/mypersonalfolder/.rvm/gems/ruby-2.7.1/gems/pry-0.14.1/lib/pry/pry_instance.rb:259
c:0025 p:0054 s:0144 e:000143 BLOCK /home/mypersonalfolder/.rvm/gems/ruby-2.7.1/gems/pry-0.14.1/lib/pry/repl.rb:77 [FINISH]
c:0024 p:---- s:0140 e:000139 CFUNC :loop
c:0023 p:0004 s:0136 E:002650 METHOD /home/mypersonalfolder/.rvm/gems/ruby-2.7.1/gems/pry-0.14.1/lib/pry/repl.rb:67
c:0022 p:0004 s:0132 E:0012f0 BLOCK /home/mypersonalfolder/.rvm/gems/ruby-2.7.1/gems/pry-0.14.1/lib/pry/repl.rb:38
c:0021 p:0010 s:0129 E:001d20 METHOD /home/mypersonalfolder/.rvm/gems/ruby-2.7.1/gems/pry-0.14.1/lib/pry/input_lock.rb:61
c:0020 p:0023 s:0125 E:002260 METHOD /home/mypersonalfolder/.rvm/gems/ruby-2.7.1/gems/pry-0.14.1/lib/pry/input_lock.rb:78
c:0019 p:0024 s:0119 E:0002c0 METHOD /home/mypersonalfolder/.rvm/gems/ruby-2.7.1/gems/pry-0.14.1/lib/pry/repl.rb:38
c:0018 p:0018 s:0115 E:002008 METHOD /home/mypersonalfolder/.rvm/gems/ruby-2.7.1/gems/pry-0.14.1/lib/pry/repl.rb:15
c:0017 p:0191 s:0110 E:0020a8 METHOD /home/mypersonalfolder/.rvm/gems/ruby-2.7.1/gems/pry-0.14.1/lib/pry/pry_class.rb:188
c:0016 p:0177 s:0103 E:0020d0 METHOD /home/mypersonalfolder/.rvm/gems/ruby-2.7.1/gems/railties-5.2.6/lib/rails/commands/console/console_command.rb:64
c:0015 p:0009 s:0099 E:002108 METHOD /home/mypersonalfolder/.rvm/gems/ruby-2.7.1/gems/railties-5.2.6/lib/rails/commands/console/console_command.rb:19
c:0014 p:0058 s:0094 E:0024a0 METHOD /home/mypersonalfolder/.rvm/gems/ruby-2.7.1/gems/railties-5.2.6/lib/rails/commands/console/console_command.rb:96
c:0013 p:0054 s:0090 E:0012a0 METHOD /home/mypersonalfolder/.rvm/gems/ruby-2.7.1/gems/thor-1.1.0/lib/thor/command.rb:27
c:0012 p:0040 s:0082 E:001a68 METHOD /home/mypersonalfolder/.rvm/gems/ruby-2.7.1/gems/thor-1.1.0/lib/thor/invocation.rb:127
c:0011 p:0235 s:0075 E:0003d8 METHOD /home/mypersonalfolder/.rvm/gems/ruby-2.7.1/gems/thor-1.1.0/lib/thor.rb:392
c:0010 p:0045 s:0062 E:0023e8 METHOD /home/mypersonalfolder/.rvm/gems/ruby-2.7.1/gems/railties-5.2.6/lib/rails/command/base.rb:69
c:0009 p:0122 s:0055 E:000ed8 METHOD /home/mypersonalfolder/.rvm/gems/ruby-2.7.1/gems/railties-5.2.6/lib/rails/command.rb:46
c:0008 p:0063 s:0044 E:000950 TOP /home/mypersonalfolder/.rvm/gems/ruby-2.7.1/gems/railties-5.2.6/lib/rails/commands.rb:18 [FINISH]
c:0007 p:---- s:0039 e:000038 CFUNC :require
c:0006 p:0012 s:0034 E:0016e0 BLOCK /home/mypersonalfolder/.rvm/gems/ruby-2.7.1/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23
c:0005 p:0039 s:0031 E:001f98 METHOD /home/mypersonalfolder/.rvm/gems/ruby-2.7.1/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/loaded_features_index.rb:100
c:0004 p:0025 s:0020 E:002310 METHOD /home/mypersonalfolder/.rvm/gems/ruby-2.7.1/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22
c:0003 p:0065 s:0014 E:0008f0 METHOD /home/mypersonalfolder/.rvm/gems/ruby-2.7.1/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31
c:0002 p:0031 s:0006 E:000560 EVAL bin/rails:4 [FINISH]
c:0001 p:0000 s:0003 E:001f00 (none) [FINISH]
... And more hundreds of lines in the console that I've omitted here to be brief
from ruby-pg.
Related Issues (20)
- Release pg-1.5.0 HOT 5
- `certs/larskanis-2023.pem` in version 1.4.6 has 0600 permissions HOT 1
- PG::Coder.new(hash) is deprecated HOT 6
- Timezone timestamp decoder behavior mismatch with hash vs. keyword arguments on v1.5.0 HOT 1
- PG 1.5.0 may have broken COPY exports HOT 2
- Seg fault after upgrading to pg v1.5.2 HOT 3
- Saw Rails DB connection pool spike after upgrading from 1.4.6 to 1.5.2 HOT 5
- failed to install pg 1.4.6 on Centos7 with ruby 3.2.0, whereas with ruby 3.1.0 it installs HOT 3
- How to build an old pg on ruby 2.3.1 HOT 1
- Segmentation fault with ruby 2.7.8 and pg 1.5.3 HOT 10
- Segmentation fault HOT 28
- Sonoma: getaddrinfo segmentation fault HOT 2
- Segmentation fault in ruby:3.2.2-alpine3.18 docker image HOT 2
- Wrong binary conversion on x86 (32bit intel) arch causing test failures HOT 4
- Bad IAM Token against Amazon Aurora Postgres: Out of memory error HOT 2
- Attempting to execute a sql file with `\set ...` raises errors HOT 3
- conn.exec writing "INFO" statements to stderr instead of stdout HOT 2
- Segfault on ruby 3.2.2, pg 1.5.4 HOT 2
- Error ruby(39749,0x1e1f05300) malloc: double free for ptr 0x13c6bfa00 HOT 1
- Segmentation fault when connecting to RDS HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ruby-pg.