mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-23 22:19:13 +00:00
the issue was related to the syncGroupsAfterLeaderboardChange method which was based on the assumption that there may be
changes in Leaderboard Java object identity while still meaning the same leaderboard. This would have forced a replacement
of listeners and an update of the leaderboards list in the LeaderboardGroup. Furthermore, LeaderboardGroup used to refer to
the leaderboard by name in the database. This forced an update to the persistent copy of the leaderboard group when the
leaderboard's name changed. Today, this link is based on a MongoDB ObjectId, so no update of the leaderboard group is
necessary any more.
The root cause was a threading issue: iterating over a copy of the leaderboards list of the leaderboard group, then
looking for the old position of the leaderboard in that list, then removing it, then adding it again at the old index.
If this is not atomically locked (which it used to be up to commit 118f03fbb5 when
coarse-grained synchronization was replaced by more fine-grained locking inside the LeaderboardGroupImpl methods) then
one of two concurrent removals for the same leaderboard may not find the leaderboard anymore, yet the second add is
carried out, leading to a duplication; or the first thread gets the index before the second thread removes; then
the first thread adds at an incorrect index.
Change-Id: Ib47ba715c77221fa353fa4669662e5f48d8e5857