# |
Dec 12th 2019, 12:59 |
steinkel |
^this |
# |
Dec 12th 2019, 12:59 |
dereuromark |
why dont they open up the connection as needed? they should trigger a php job, open and close after done. |
# |
Dec 12th 2019, 12:59 |
info315 |
but this issue is beyond the queue. because my worker is a php daemon (a cakephp command to be exactly). |
# |
Dec 12th 2019, 12:58 |
info315 |
RabbitMq and Gearman |
# |
Dec 12th 2019, 12:58 |
dereuromark |
what queue solution are you using? the right ones all dont have these issues. |
# |
Dec 12th 2019, 12:58 |
info315 |
i just need to reconnect to the database, thats all. |
# |
Dec 12th 2019, 12:57 |
info315 |
i dont have any memory issues |
# |
Dec 12th 2019, 12:57 |
steinkel |
you get rid of potential memory leaks for long running php daemons this way too |
# |
Dec 12th 2019, 12:57 |
info315 |
so there is no public method to reconnect to the database? |
# |
Dec 12th 2019, 12:56 |
steinkel |
@info315 in that case I usually set the daemon to die after processing X jobs, and configure monit or systemd to keep it alive |
# |
Dec 12th 2019, 12:56 |
dereuromark |
well, with that we dont have any such issue at all. |
# |
Dec 12th 2019, 12:56 |
info315 |
@dereuromark i have a job queue |
# |
Dec 12th 2019, 12:56 |
dereuromark |
nook24: you might want to use a job queue instead :slightly_smiling_face: |
# |
Dec 12th 2019, 12:51 |
slackebot2 |
error. For this reason my cake2 daemon just reconnects to the database straight after it gets a new job. This is no "my query is slow", "or your code is bad" issue. |
# |
Dec 12th 2019, 12:51 |
info315 |
Its not a long running SQL query... I have a daemon which is running in the background 24/7. It sleeps until it gets a job todo. By default, CakePHP connects to the database, if the daemon starts (`systemctl stat foo.service`). If the daemon now sleeps for 3 days because of there is no job to do, the database server close the connection. If than Cakephp wants to query something because of an incoming job, you get an mysql has gone away |
# |
Dec 12th 2019, 12:51 |
jotpe |
Maybe you need the field to be accessible? |
# |
Dec 12th 2019, 12:50 |
jotpe |
:thinking_face: |
# |
Dec 12th 2019, 12:49 |
neon1024 |
Yes, it seems to be fine in the entity, but when it hits Twig is vanishes |
# |
Dec 12th 2019, 12:48 |
jotpe |
? |
# |
Dec 12th 2019, 12:48 |
jotpe |
And in your Controller its working @neon1024 |
# |
Dec 12th 2019, 12:47 |
neon1024 |
https://book.cakephp.org/3/en/orm/entities.html#accessors-mutators |
# |
Dec 12th 2019, 12:47 |
kevin.pfeifer |
i dont know what you mean with ``Entity accessor methods`` |
# |
Dec 12th 2019, 12:47 |
neon1024 |
Of what? An example of `null`? |
# |
Dec 12th 2019, 12:46 |
kevin.pfeifer |
example? |
# |
Dec 12th 2019, 12:45 |
neon1024 |
Anyone using Twig for templating having any issues with Entity accessor methods being NULL in the template |
# |
Dec 12th 2019, 12:45 |
neon1024 |
@jotpe Heading out in the rain at lunchtime to vote |
# |
Dec 12th 2019, 12:43 |
jotpe |
_how do i fix long running tasks? ->_ Call out general elections :troll: Hope you UK guys are decide wisely :uk: :flag-eu: |
# |
Dec 12th 2019, 12:42 |
neon1024 |
Or use a message queue |
# |
Dec 12th 2019, 12:42 |
kevin.pfeifer |
split your tasks for your background daemon into several smaller tasks so the database can respond for each small task? |
# |
Dec 12th 2019, 12:41 |
info315 |
I have a background daemon and it needs an method to reconnect to the DB... There is no other fix for this i guess |
# |
Dec 12th 2019, 12:40 |
neon1024 |
That’s the “How long is a piece of string?” question |
# |
Dec 12th 2019, 12:40 |
neon1024 |
Lots of ways, benchmark it, streamline it, chunk it, depends what it is, what it’s doing, where it’s running, and about 3.14m other variables |
# |
Dec 12th 2019, 12:39 |
info315 |
@neon1024 how do i fix long running tasks? |
# |
Dec 12th 2019, 12:38 |
ndm |
Doesn't 1 reconnect attempt happen automatically now? |
# |
Dec 12th 2019, 12:38 |
neon1024 |
Fix the script? |
# |
Dec 12th 2019, 12:35 |
info315 |
Is there a CakePHP 4 way to reconnect to the database to avoid mysql has von away issues for long running console scripts like i did in cake2? ``` // Avoid "MySQL server has gone away" $this->Cake->Systemsetting->getDatasource()->reconnect();``` |
# |
Dec 12th 2019, 10:47 |
boydbuenodemesquita |
I'm running in situations sometimes where my migrations fail halfway through. Stranding the database in a situation where migrate and rollback are both error. So I was checking for ways to reduce the change of that happening, so checking the queries after the migration will not solve that. Although I'm not sure if seeing the queries will actually help with anything. :P |
# |
Dec 12th 2019, 10:44 |
steinkel |
@boydbuenodemesquita poor man's dry-run would be: take a db-dump, enable query debug, run migrations, restore dump :slightly_smiling_face: |
# |
Dec 12th 2019, 10:35 |
boydbuenodemesquita |
Thanks for the help! |
# |
Dec 12th 2019, 10:33 |
boydbuenodemesquita |
Ah, might be that the current version doesn't support it. :( |
# |
Dec 12th 2019, 10:33 |
neon1024 |
Use `-h` to see options for any shell command 8) |