MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / release

Function release

packages/internal/src/db/advisory-lock.ts:152–177  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

150 }
151 },
152 async release() {
153 if (isReleased) {
154 logLock('info', 'Lock release called but already released', { lockId })
155 return
156 }
157 logLock('info', 'Releasing advisory lock', { lockId, healthCheckCount })
158 isReleased = true
159 if (healthCheckTimer) {
160 clearInterval(healthCheckTimer)
161 healthCheckTimer = null
162 }
163 try {
164 // Explicitly release the advisory lock before closing connection
165 logLock('info', 'Calling pg_advisory_unlock', { lockId })
166 await connection`SELECT pg_advisory_unlock(${lockId})`
167 logLock('info', 'Advisory lock released via pg_advisory_unlock', { lockId })
168 } catch (error) {
169 logLock('error', 'Error during pg_advisory_unlock (continuing to close connection)', { lockId, error: String(error) })
170 }
171 try {
172 await connection.end()
173 logLock('info', 'Database connection closed', { lockId })
174 } catch (error) {
175 logLock('error', 'Error closing database connection', { lockId, error: String(error) })
176 }
177 },
178 }
179
180 return { acquired: true, handle }

Callers

nothing calls this directly

Calls 1

logLockFunction · 0.85

Tested by

no test coverage detected