ampedandwired / bamboo-mutex-plugin

Bamboo plugin that prevents plans from running simultaneously
MIT License
7 stars 7 forks source link

Use thread-safe map to track active plans. #2

Open erikrozendaal opened 10 years ago

erikrozendaal commented 10 years ago

Before whenever two or more plans started simultaneously a deadlock would occur, as each plan found the other already running.

This fix uses a thread-safe map to track the plan that currently holds the mutex. When the plan finishes the mutex is cleared. If a plan dies without clearing the mutex a plan awaiting the mutex will perform the cleanup instead.

The implementation does assume that the pre- and post-chain actions run in a single JVM. Hopefully this is actually true...

This fix has been running in our Bamboo installation for a while and works for us without deadlocks. This fixes issue #1.