Closed cptaffe closed 7 years ago
This was my fault. Not sure why the inconsistency between OS X and Linux, but the problem is that I initialize the database object in one process, then fork workers. Since the workers are using the same socket this obviously leads to a race condition
Ultimately the fix was to call close
on the database object once forked
Yeah also not sure why there'd be a difference between os x and linux here, but thanks for posting, it should help others find the answer when they run into it.
I don't get this issue when running my server on my local machine (OS X), but I do get it when running it in a docker image on my local machine, and in ECR (docker images use
crystallang/crystal:0.23.1
and installlibpq-dev
).I think this is a race condition, it doesn't seem to show up until there are two concurrent requests sending queries. Once it errors each subsequent request errors and the only fix is to restart the process.
The backtrace I get looks like:
Or
Or
Stress testing a fresh process on Linux looks like:
And on OS X (no issue):