Closed Gounlaf closed 6 years ago
@Gounlaf - Sorry for the delay in reply.
If there's an exception it can sometimes close the entity manager and it has to be reopened to continue. Is it your code causing the exception or the queue itself?
Hi @mmucklo,
Don't worry for the delay :)
Is it your code causing the exception or the queue itself? It's my code! And yup, I got a problem with my entity; trying to flush it cause the em to be closed. Since it's the same em as the queue (the "default" one), the queue is not updated.
So... I saw "nothing", and the only error logged was "the em is closed".
Edit: issue closed by missclick ><
@Gounlaf - I suppose there’s a trick I could do to see if the Entity Manager was closed and then try to reopen it. The only problem is it might mask other issues - but it may help your problem...
The only problem is it might mask other issues
@mmucklo What do you mean?
I can create another EM so there is one "independent" for the workers, and another for the "job" itself. But I don't know if it's a good idea.
Btw, since EM is defined in config (dtc_queue[orm][entity_manager]=default), Now I think I should use two differents EM: one for the queue (that will have no reason to be closed), another one the job itself. So queue can continue to execute jobs, even if there are error during their execution
@Gounlaf - I have a PR open which should provide a fix, regardless.
I will probably merge it later today after trying to write a test for it.
@Gounlaf - can you see if 4.4.0 fixes the issue for you?
@Gounlaf, any word?
Sorry @mmucklo I haven't tested yet. Will do today evening
@mmucklo It seems to be working as expected :)
I've deliberately create a UniqueConstraintViolationException with my entity, and job status correctly set to "exception".
Thanks for taking care of my request!
@Gounlaf, you’re welcome!
@Gounlaf, you’re welcome!
Hi all, I just came across this bundle and this issue. I'd like to add my 2 cents.
It's generally a bad idea to mix an application's entity / document manager from doctrine with an ancillary tool such as this queue. The reasons are:
$om->flush()
's in the application affect the queue and vice versa.A better solution is to create a separate entity manager or document manager for the queue. This does not mean we need 2 connections. You can share 1 DBAL
connection between 2 EntityManager
s.
E.g.:
MongoODM
config.yml
doctrine_mongodb:
connections:
default:
server: '%mongo_server%'
default_database: '%mongo_database%'
document_managers:
default:
mappings:
App:
type: annotation
dir: '%kernel.project_dir%/src/Document'
prefix: App\Document
queue:
connection: default
mappings:
DtcQueueBundle: ~
dtc_queue:
odm:
document_manager: queue
manager:
job: odm
DoctrineORM
config.yml
doctrine:
dbal:
driver: pdo_mysql
host: '%database_host%'
dbname: '%database_name%'
user: '%database_user%'
password: '%database_password%'
orm:
entity_managers:
default:
mappings:
App:
type: annotation
dir: '%kernel.project_dir%/src/Entity'
prefix: App\Entity
queue:
mappings:
DtcQueueBundle: ~
dtc_queue:
orm:
entity_manager: queue
manager:
job: orm
Hi @mmucklo,
I'm encountering a weird issue: when an error happen, not "all the stack" is logged. As example, I have an issue with a doctrine entity, which prevent it to be persisted correctly.
If I catch and dump manually the exception, I got full details.
But in logs, I got only:
Everything is rollback, entity manager is closed, so the job status is not set to "exception".
If I don't "logs" manually the exception, I can't understand why the EM was closed.
Have you any idea how to log "everything" in the system logs? (I don't know if "you" are logging it, or if it's the symfony console component that handle it itself.) It seems that an EM can't be re-opened when it was closed: I can create another EM so there is one "independent" for the workers, and another for the "job" itself. But I don't know if it's a good idea.
If I'm not under-stable... I will try to explain it better =/
Thanks,
Regards.