Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposed changes
This fixes a deadlock that occurs whenever a repository that was imported from another repository with existing pushlogs receives a post receive repository hook.
This deadlock occured,
because on the event the PushlogManager creates a semaphore based on the id of the repository. After the pushlog has been written, the manager tries to find and unlock this semaphore based on the repository id stored in the pushlog. If the repository is an imported one with a pushlog that has been created beforehand in the original repository, this stored repository id differs from the actual id of the current repository. Therefore the semaphore has not been found and the lock stayed in place.
Whenever a second event has been fired for such a repository, the manager cannot pass the semaphore, because it still is locked. This can lead up to a complete block of the core event bus of SCM-Manager so that no asynchronous event whatsoever can be processed any more. This is the case, because the event bus does not call hooks of the same type (in this case the PushlogHook) in parallel. Therefore all further pushlog hooks will have to wait for the event that has been blocked in the first place, which will eventually block all threads of the event bus.
To fix this, this commit removes the redundant and error prone repository id from the pushlog and uses the id of the repository the event was triggered for in both places, the lock and the unlock of the semaphore.
Because a removed fields are ignored by the xml parser loading the pushlog enties, we do not have to adapt the data in an update step. The repository id (and while we're at it the unused 'dataVersion', too) simply will be omitted whenever the pushlog is changed for a repository the next time.
Your checklist for this pull request
Put an
x
in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.Contributor:
gradle/changelog
Reviewer:
Checklist for branch merge request (not required for forks)