问题
In a GWT based application (Google Gerrit in particular), I'm getting an exception (while executing the gerrit review
command):
com.google.gwtorm.server.OrmConcurrencyException: Concurrent modification detected
at com.google.gwtorm.jdbc.JdbcAccess.execute(JdbcAccess.java:449)
at com.google.gwtorm.jdbc.JdbcAccess.updateAsBatch(JdbcAccess.java:270)
at com.google.gwtorm.jdbc.JdbcAccess.update(JdbcAccess.java:223)
Is there a way to identify which data in particular caused the concurrency error?
Looking at the source code of GWT ORM, I'm assuming the UPDATE
prepared statement didn't match the data to update and as a result nothing was updated. Finally, the OrmConcurrencyException
was thrown to inform the caller.
回答1:
This can happen when gerrit review
is executed in parallel.
For instance, as reported at https://code.google.com/p/gerrit/issues/detail?id=3730&thanks=3730&ts=1450711628, updating a --label
of two different labels causes this error:
bash-3.2$ ssh robot@gerrit.foo.int gerrit review --label Verified=-1 \
--message '"Verified .. -1."' 2463,9 & \
ssh robot@gerrit.foo.int gerrit review --label Tested=+1 \
--message '"Tested .. +1."' 2463,9 &
[3] 29329
[4] 29330
bash-3.2$
bash-3.2$ error: Cannot post review
one or more reviews failed; review output above
[3] Done ssh robot@gerrit.foo.int gerrit review --label Verified=-1 --message '"Verified .. -1."' 2463,9
[4] Exit 1 ssh robot@gerrit.foo.int gerrit review --label Tested=+1 --message '"Tested .. +1."' 2463,9
It should be just ok to re-trigger one of the commands once again (or fix the reported issue).
来源:https://stackoverflow.com/questions/34397547/gwt-orm-ormconcurrencyexception-concurrent-modification-detected-find-the-cau