List all lock records. Returns: List of dicts with all lock holder information
(self)
| 330 | conn.close() |
| 331 | |
| 332 | def list_all_locks(self) -> list[dict[str, Any]]: |
| 333 | """List all lock records. |
| 334 | |
| 335 | Returns: |
| 336 | List of dicts with all lock holder information |
| 337 | """ |
| 338 | conn = self._get_connection() |
| 339 | try: |
| 340 | cursor = conn.cursor() |
| 341 | cursor.execute( |
| 342 | "SELECT lock_name, owner_pid, lock_mode, operation, hostname, acquired_at " |
| 343 | "FROM lock_holders ORDER BY lock_name, acquired_at" |
| 344 | ) |
| 345 | rows = cursor.fetchall() |
| 346 | return [ |
| 347 | { |
| 348 | "lock_name": r[0], |
| 349 | "owner_pid": r[1], |
| 350 | "lock_mode": r[2], |
| 351 | "operation": r[3], |
| 352 | "hostname": r[4], |
| 353 | "acquired_at": r[5], |
| 354 | } |
| 355 | for r in rows |
| 356 | ] |
| 357 | finally: |
| 358 | conn.close() |
| 359 | |
| 360 | def cleanup_stale_locks(self) -> int: |
| 361 | """Remove all lock rows where owner PID is dead. |