I am working on an app which has the web component (visited via browser) and background task processing component, to which web component delegates some long running stuff.
I've just hit an issue when I refreshed my web browser only to find it loading indefinitely (first spotted in AJAX
, but later in normal request).
It did not really look apparent but as soon as I shut down the background Symfony
command which also utilizes EntityManager
the browser get unblocked and proceeds with request.
My app uses RabbitMQ
to store job requests which are publish by web component. The Symfony
command uses the same "backbone" to create RabbitMQ
consumer and take consume those jobs.
I tried, without any result:
Apache
RabbitMQ
RabbitMQ
queueEntityManagers
for web and commandI use OldSoundRabbitMqBundle
(link) to facilitate communication between those two.
The web component gets stuck regardless of action being called (not related to RabbitMQ
producer).
Has anyone stumbled upon similar issue?
This happens on dev box, I haven't got around giving it a spin on a production server, nor would I until I find out more about this.
It would seem that I misused the locking mechanism in Postgres. Indeed the task processing component is a long-running task, but given that it is Symfony command, Doctrine connection is being established as early as possible.
Now comes the tricky part: I used the LOCK TABLE
statement to lock some tables away from concurrent access (EXCLUSIVE
type). Without closing the connection (not entity manager), those locks are left intact, until I restart the command (every 10th task).
This was the root cause.
I am still investigating some edge-cases, but since I moved away to advisory locking, I had no more lock-ups.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With