MCPcopy Create free account
hub / github.com/bytebase/bytebase / AcquireAdvisoryXactLockWithStringKey

Function AcquireAdvisoryXactLockWithStringKey

backend/store/advisory_lock.go:90–93  ·  view source on GitHub ↗

AcquireAdvisoryXactLockWithStringKey acquires a transaction-level advisory lock scoped by namespace and string key, blocking until the lock is available. The lock is automatically released when the transaction ends.

(ctx context.Context, tx *sql.Tx, namespace AdvisoryLockKey, key string)

Source from the content-addressed store, hash-verified

88// lock scoped by namespace and string key, blocking until the lock is available.
89// The lock is automatically released when the transaction ends.
90func AcquireAdvisoryXactLockWithStringKey(ctx context.Context, tx *sql.Tx, namespace AdvisoryLockKey, key string) error {
91 _, err := tx.ExecContext(ctx, "SELECT pg_advisory_xact_lock($1, hashtext($2))", int32(namespace), key)
92 return err
93}
94
95// Release releases the advisory lock and returns the connection to the pool.
96// Uses context.Background() to ensure cleanup completes even if parent ctx is cancelled.

Callers 1

TouchVCSProviderUserMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected