MCPcopy Create free account
hub / github.com/PostHog/duckgres / releaseSem

Method releaseSem

server/attach_timeout.go:172–192  ·  view source on GitHub ↗

releaseSem returns the attach semaphore slot acquired by the caller. If any statement was abandoned past its deadline, the release is handed to a goroutine that waits for the underlying CGO call(s) to actually finish first — the semaphore exists to serialize attach work on the database, and a hung A

(sem chan struct{})

Source from the content-addressed store, hash-verified

170//
171// No-op when sem is nil (callers that run without the semaphore).
172func (a *attachStepExecer) releaseSem(sem chan struct{}) {
173 if sem == nil {
174 return
175 }
176 a.mu.Lock()
177 abandoned := a.abandoned
178 a.abandoned = nil
179 a.mu.Unlock()
180 if len(abandoned) == 0 {
181 <-sem
182 return
183 }
184 go func() {
185 for _, st := range abandoned {
186 <-st.done
187 }
188 slog.Warn("Abandoned catalog attachment statement(s) finished; releasing attach semaphore.",
189 "count", len(abandoned))
190 <-sem
191 }()
192}
193
194// attachSQLRunner abstracts the statement runner shared by createS3SecretWith
195// so catalog-attachment paths run under per-step deadlines (attachStepExecer)

Calls

no outgoing calls