You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
MySQL/Firestore datastore.Iterator leaks connections on decode error
Description
pkg/datastore/datastore.go (Iterator interface has no Close()), pkg/datastore/mysql/iterator.go:38-52
List() calls across the datastore layer can return early on a row/document decode error without releasing the underlying sql.Rows/Firestore iterator.
No SetMaxOpenConns is configured, so repeated failures can accumulate unreleased database resources. ListNotCompletedDeployments and similar methods are polled continuously by every piped instance, meaning a single malformed/incompatible row could eventually exhaust available MySQL connections and impact datastore operations across the control plane.
This ensures the underlying database/Firestore iterator is released both on successful iteration and when iteration exits early because of a decode error.
Verification
The MySQL implementation can return from iteration when row decoding fails without closing the underlying sql.Rows. The Firestore implementation should be verified for the same lifecycle issue.
Title
MySQL/Firestore
datastore.Iteratorleaks connections on decode errorDescription
pkg/datastore/datastore.go(Iteratorinterface has noClose()),pkg/datastore/mysql/iterator.go:38-52List()calls across the datastore layer can return early on a row/document decode error without releasing the underlyingsql.Rows/Firestore iterator.SetMaxOpenConnsis configured, so repeated failures can accumulate unreleased database resources.ListNotCompletedDeploymentsand similar methods are polled continuously by every piped instance, meaning a single malformed/incompatible row could eventually exhaust available MySQL connections and impact datastore operations across the control plane.json.Unmarshalerror in the same MySQL iterator but does not address iterator/resource cleanup.Suggested fix
Add
Close() errorto thedatastore.Iteratorinterface and ensure every caller closes the iterator immediately after obtaining it:This ensures the underlying database/Firestore iterator is released both on successful iteration and when iteration exits early because of a decode error.
Verification
The MySQL implementation can return from iteration when row decoding fails without closing the underlying
sql.Rows. The Firestore implementation should be verified for the same lifecycle issue.