Skip to content

Commit cb6f05b

Browse files
EDsCODEclaude
andcommitted
Detach DuckLake before closing connection to release RDS connections
When a client disconnects, explicitly DETACH the ducklake catalog before closing the DuckDB connection. This ensures the DuckLake extension properly releases its connection to the RDS metadata store, preventing connection leaks. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 20a00c7 commit cb6f05b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

server/conn.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ func (c *clientConn) serve() error {
8888
// Ensure the database connection is closed when this client disconnects
8989
defer func() {
9090
if c.db != nil {
91+
// Detach DuckLake to release the RDS metadata connection
92+
if c.server.cfg.DuckLake.MetadataStore != "" {
93+
if _, err := c.db.Exec("DETACH ducklake"); err != nil {
94+
log.Printf("Warning: failed to detach DuckLake for user %q: %v", c.username, err)
95+
}
96+
}
9197
c.db.Close()
9298
log.Printf("Closed DuckDB connection for user %q", c.username)
9399
}

0 commit comments

Comments
 (0)