I have a problem that's just baffling me and I'm hoping it rings a bell with someone.
I have a SortedSet of events, here's the .hbm snippet.
<set name="events" table="CAPTURE_EVENT" cascade="all" sort="natural">
I only ever add to the set, I never delete. The events are added when my finite state machine moves through states. The state machine is syncronized, there is never a case where two separate threads will simultaenous add events to the SortedSet. Each event starts a Hibernate transaction and commits it when the event has been processed. No sub-threads are spawned while processing the event. Each time an event comes in a copy of the object holding the SortedSet of events is read from the database (I'm not caching anything manually).
What's baffling me is most of the time I see Hibernate insert a row for a new event, which is expected. Occassionally (1 out of 5 or 6 times) it will add the new event AND delete a previous event. Again, my code never deletes from the SortedSet so this delete is undesired. Here's some snippets of the SQL:
- enter FSM
2005-03-14 09:05:00,226 [TaskExecutorService-2] INFO STDOUT Hibernate: insert into PACKAGER.CAPTURE_EVENT (CAPTURE_ID, OCCURRED_AT, EVENT_TYPE, SEVERITY, MESSAGE) values (?, ?, ?, ?, ?)
2005-03-14 09:05:00,226 [TaskExecutorService-2] INFO STDOUT Hibernate: update PACKAGER.CAPTURE_FSM_STATE_NAMES set STATE_NAME=? where CAPTURE_ID=? and VIDEO_SERVER=?
- exit FSM
- enter FSM
2005-03-14 09:05:00,319 [TaskExecutorService-3] INFO STDOUT Hibernate: delete from PACKAGER.CAPTURE_EVENT where CAPTURE_ID=? and OCCURRED_AT=? and EVENT_TYPE=? and SEVERITY=? and MESSAGE=?
2005-03-14 09:05:00,335 [TaskExecutorService-3] INFO STDOUT Hibernate: insert into PACKAGER.CAPTURE_EVENT (CAPTURE_ID, OCCURRED_AT, EVENT_TYPE, SEVERITY, MESSAGE) values (?, ?, ?, ?, ?)
- exit FSM
Now, you can see it's two different threads (TaskExecutorService-2 and TaskExecutorService-3), but one waits for the other to finish.
I've spent about 3 days trying to figure it out and I'm absolutely stumped. I realize this isn't a tremendous amount to go on, but hopefully someone will recognize the problem and know the cause.
I've tried searching through the form and haven't found anything quite like it.
|