Commit ac233ee
committed
fix(postgres): bind every placeholder in the table-stats query
getTableStats built a query with NINE `?` placeholders — the two size
subtractions use two each — while the binding loop ran `for (i = 1; i <= 7)`.
Parameters 8 and 9 were never set, so Postgres rejected every call with
No value specified for parameter 8
That silently disabled table-growth snapshots for every table on every Postgres
connection: TableGrowthMonitoringService logs the failure per table and carries
on, so the scheduled job "succeeded" while capturing nothing. It shows up in the
backend log as a steady stream of
✗ Failed to capture snapshot for table: dba_batch_job_execution - No value
specified for parameter 8.
The query now binds one value and references it through a CTE, so the count
cannot drift again — counting placeholders by hand is precisely what failed here.
Verified against a live Postgres 18: the old form reports 9 parameters via
pg_prepared_statements, the new one reports 1 and returns correct sizes for
dba_batch_job_execution, the exact table from the log.
MySQL's getTableStats was checked and is unaffected (2 placeholders, 2 bound).
Tests: the existing getTableStats_returnsStats passed throughout the bug, because
a mocked PreparedStatement does not enforce that placeholders are bound. The new
test compares the two directly — it fails against the pre-fix provider with
"Wanted 9 times" while the other 10 tests still pass, which is exactly why this
reached production.1 parent 8a8483e commit ac233ee
2 files changed
Lines changed: 56 additions & 10 deletions
File tree
- backend/src
- main/java/com/dbaagent/provider/postgres
- test/java/com/dbaagent/provider/postgres
Lines changed: 20 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
223 | 223 | | |
224 | 224 | | |
225 | 225 | | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
226 | 236 | | |
| 237 | + | |
227 | 238 | | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
235 | 247 | | |
236 | 248 | | |
237 | 249 | | |
238 | | - | |
239 | | - | |
240 | | - | |
| 250 | + | |
241 | 251 | | |
242 | 252 | | |
243 | 253 | | |
| |||
Lines changed: 36 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
13 | 15 | | |
| 16 | + | |
14 | 17 | | |
| 18 | + | |
15 | 19 | | |
16 | 20 | | |
17 | 21 | | |
| |||
171 | 175 | | |
172 | 176 | | |
173 | 177 | | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
174 | 210 | | |
175 | 211 | | |
176 | 212 | | |
| |||
0 commit comments