decK sync: multiple instances connecting to single database

I have multiple kong instances (the number is dependent on the server load) connecting to the same postgres database.

When an instance starts, the deck sync command is executed to populate or update the database. While the chance is very low that two instances execute the deck sync around the same time, it looks like the consequences can be devastating:

(decK manual)

  • Always ensure that you have one decK process running at any time. Multiple processes step on each other and can corrupt Kong’s configuration.*

Is there any way to avoid this? Is there some locking strategy that can be applied or some check to know if a deck process is working on the database?