MigrationLock

internal class MigrationLock(schema: String, table: String, timeout: Duration)

The advisory lock that makes two instances starting at once safe.

It waits rather than giving up on the spot, bounded by lock_timeout - the instance that lost the race should start a moment later, not fail to start. The key comes from the history table's name, so two applications keeping separate histories in one database do not wait for each other.

Constructors

Link copied to clipboard
constructor(schema: String, table: String, timeout: Duration)

Functions

Link copied to clipboard
fun <T> withLock(session: OctaviusSessionOperations, block: () -> T): T

Takes the lock, runs block, and gives the lock back however that went.