-
Type:
Bug
-
Resolution: Fixed
-
Priority:
Medium
-
Affects Version/s: 2.5, 2.5.1, 2.5.2, 2.5.3, 2.5.4
-
Component/s: None
-
Environment:
MSSQL
When HibernateConfluenceBandanaRecordDao class is used by 2 threads there is a possibility of deadlock because saveOrUpdate method is synchronized.
Together with database locking it may produce a deadlock.
In this case "Invite" plug-in runs two threads once a day (Remove Unnecessary Invitations Job and Expire Invitations Job). Both use saveOrUpdate synchronized method in a loop.
One of the threads enters saveOrUpdate method and locks the Bandana table in the database - when it exists the method the table is still locked as transaction is not yet committed.
When another thread enters the same method it cannot proceed because database is locked. The initial thread cannot finish its own transaction and commit changes because
it cannot enter the saveOrUpdate method again as the second thread holds the lock on HibernateConfluenceBandanaRecordDao. Hence there is a deadlock.
Synchronization of saveOrUpdate looks redundant as no class instance variables are used in this method. Fix should probably be as simple as removing synchronization.