Hi,
Answer to myself : this was a threading issue ! I separated the
commits in a different context and everything works fine. Don't udpate
and commit at the same time in a context, as the Cayenne documentation
state, the ObjectContext is not thread safe so you have to take care of
synchronization yourself !
Regards,
Laurent.
Le 09/27/2011 10:25 AM, Laurent Marchal a écrit :
Hi guys,
I've been successfully used Cayenne for years now, but we have a
really weird issue right now : Cayenne is committing columns that are
never modified in our code.. I'm pretty sure Cayenne is not the
problem, but more the way we use it and I'd like your help on Cayenne
internals to discover where it comes from.
In our product we manipulate jobs (tasks), and you can change their
statuses (stop/start/restart...etc). For some reason when we commit
the status of a job Cayenne randomely updates another one (or more).
This is happening quite a lot and we discovered the issue because we
have triggers auditing the database. Here's an extract of the audit :
_Change Date Time_ _UserID_ _DB Table_ _JobName_
_COLUMN_ _Before Value_ _After Value
_
2010-12-09 08:00:52.700 teixeira SMASTER_AUX ARCANO-PUT Change
Reason (Record Added) Force Restart : (Teixeira on
09/12/2010 08:00)
2010-12-09 08:00:52.707 teixeira SMASTER ARCANO-PUT Job
Status Failed Wait to Start
2010-12-09 08:00:52.723 teixeira SMASTER NXGLoadPosLe Job
Status Finished OK Job Running
2010-12-09 08:00:52.723 teixeira SMASTER NXGLoadPosLe Exit
Description 0000000000 Pid = 4456
2011-01-14 19:29:10.763 oper-jla SMASTER_AUX LODH-REC-T Change
Reason (Record Added) Skip : RZU (Oper-JLA on 14/01/2011
19:29)
2011-01-14 19:29:10.773 oper-jla SMASTER G2-RECONSO Job
Status Finished OK Job Running
2011-01-14 19:29:10.773 oper-jla SMASTER G2-RECONSO Exit
Description 0000000000 Pid = 8968
2011-01-14 19:29:10.783 oper-jla SMASTER LODH-REC-T Job
Status Wait Job Dependency Job to be Skipped
You can see here that when the job ARCANO-PUT is updated, the job
/NXGLoadPosLe /gets updated too. Same for /G2-RECONSO /who gets
updated along with LODH-REC-T. You can think that it's a pretty normal
behavior (if the objects are modified in the same ObjectContext
they'll be commited together) but I'm sure we NEVER modify the column
_Exit Description_ ! In the other hand there is a thread that
regularly updates those jobs from the database so Cayenne can refresh
this _Exit Description_ column.
My guess is that while a refresh is made from the DB and the _Exit
Description_ is updated, a commit is made at the same time. Can it
cause that issue ? What happens if a thread update/refresh the jobs
while another commits on the same ObjectContext ?
Thank you for your help on this.
Laurent