We have next problems. Application access to few entities by timer from different application servers, and should update processing time. For removing concurrent problems we try to lock entity with getHibernateTemplate().lock(<entity>, LockMode.UPGRADE_NOWAIT) and handling exceptions CannotAcquireLockException and LockAcquisitionException. If there are no exceptions, we continue process entity and update processing time, if we don't lock entity, we skip it and try to process next enity. It's works, but JDBCExceptionReporter writes error to log if 2 applications from different application servers try to lock same entity. Example of processing one time event in both servers:
server 1 lock entity 1, server 2 write error,
server 1 lock entity 2, server 2 write error,
server 1 write error, server lock entity 3.
Also according to documentation if session throw exception we can't continue working with session.
Can anybody help to resolve this problems:
1. Remove error from log
2. Determinate what entity locked or not and lock if not locked in atomic operation without exception.
|