Hi Hans,
[email protected] wrote:
Hi,
I have an strange behavior with transactions.
I have a system where users must upload a document and then wait for this to be
aproved:
How long will the approval process take? Is this a manual task?
The problem is that if i open "more than one document uploading window" and
press submit at once, eventually a race condition arise and two documents get registered,
breaking the business rule.
Playing with the filter configuration in web.xml, i changed session-scope to
true.
Magically this make the things work as expected and you can only upload one
document, and the race condition is eliminated.
I assume you are using Cayenne?
What most likely happens with session-scope is that your transaction
blocks the second upload request at the session level. Once it commits
the second request is processed.
This solves the problem, but introduces another worst, sessions now see stale
data, each session has its own version of the instances.
The DataContextFilter has a "autoRollback" property (defaults to true)
which automatically rolls back uncommitted changes in the DataContext.
Have you set this to false perhaps? You should not see stale data if
you rollback uncommitted changes.
kind regards
bob