Package org.keycloak.models.dblock
Interface DBLockProvider
- All Superinterfaces:
Provider
- All Known Implementing Classes:
LiquibaseDBLockProvider
Global database lock to ensure that some actions in DB can be done just be one cluster node at a time.
There are different namespaces that can be locked. The same DBLockProvider (same session in keycloak) can only be used to lock one namespace, a second attempt will throw a RuntimeException. The hasLock method returns the local namespace locked by this provider.
Different DBLockProvider instances can be used to lock in different threads. Note that the DBLockProvider is associated to the session (so in order to have different lock providers different sessions are needed).
- Author:
- Marek Posolda
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic enum
Lock namespace to have different lock types or contexts. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Will destroy whole state of DB lock (drop table/collection to track locking).Returns the current provider namespace locked or nullvoid
Release previously acquired lock by this provider.boolean
void
Try to retrieve DB lock or wait if retrieve was unsuccessful.
-
Method Details
-
waitForLock
Try to retrieve DB lock or wait if retrieve was unsuccessful. Throw exception if lock can't be retrieved within specified timeout (900 seconds by default) Throw exception if a different namespace has already been locked by this provider.- Parameters:
lock
- The namespace to lock
-
releaseLock
void releaseLock()Release previously acquired lock by this provider. -
getCurrentLock
DBLockProvider.Namespace getCurrentLock()Returns the current provider namespace locked or null- Returns:
- The namespace locked or null if there is no lock
-
supportsForcedUnlock
boolean supportsForcedUnlock()- Returns:
- true if provider supports forced unlock at startup
-
destroyLockInfo
void destroyLockInfo()Will destroy whole state of DB lock (drop table/collection to track locking).
-