Commit 4ddb3e2
154028: sql: Fix idle latency tracking r=alyshanjahani-crl a=alyshanjahani-crl
Previously idle latencies were not being tracked accurately in two situations.
First, there was massive over counting of idle latencies in transactions that had INSERTs with placeholders (more generally statement that executed a prepare/bind before running). See issue #146116.
In these situations we had missed setting the QueryServiced time for the statements within the transaction, resulting in all the intermediate idle latencies calulating their `waitingSince` from the transaction start time.
The control flow of the conn executor can be difficult to track and through adding print statements, the difference between a transaction with `INSERT INTO ... VALUES (1)` vs `INSERT INTO ... VALUES ($1)` highlighted that setting QueryServiced at the end of the `ExecStmt` case in `execCmd` meant that for the prepare/bind version of the INSERT statements, we never set QueryServiced.
Simple statements:
```
execCmd ExecStmt
execStmtInOpenState INSERT INTO test_idle VALUES (1)
execCmd Setting QueryServiced
execCmd ExecStmt
execStmtInOpenState INSERT INTO test_idle VALUES (1)
execCmd Setting QueryServiced
execCmd ExecStmt
execStmtInOpenState INSERT INTO test_idle VALUES (1)
execCmd Setting QueryServiced
```
Notice how after every `execStmtInOpenState`, the flow returns to `execCmd`. Whereas in the case below, we just flow back into `execStmtInOpenState`.
Prepare/bind statements:
```
prepare statsCollector.Reset
bind statsCollector.Reset
execStmtInOpenState INSERT INTO test_idle VALUES ($1)
prepare statsCollector.Reset
bind statsCollector.Reset
execStmtInOpenState INSERT INTO test_idle VALUES ($1)
prepare statsCollector.Reset
bind statsCollector.Reset
execStmtInOpenState INSERT INTO test_idle VALUES ($1)
```
The second situation in which idle latencies were not tracked correctly was when observer statements were run in between statements in the transaction. This is a situation that occurs when using the `cockroach sql` cli. In this case, idle latencies were severely undercounted because we'd reset the stats collector before running the observer statement, and then when the non observer statement ran and we recorded the statement summary, the idle latency would be calculated from the previous observer statement time.
This commit fixes the first situation by additionally setting QueryServiced after `execStmt`.
This commit fixes the second situation by accumulating idle latencies in between observer statements.
Lastly this commit removes the existing TestSQLStatsIdleLatencies as it evidently had poor coverage and replaces it with TestTransactionLatencies which enforces invariants like:
totalTxnTime >= txnServiceLatency >= txnIdleLatency
p.s debugging session phase times is really tedious and we should consider refactoring.
Fixes: #146116
Release note (bug fix): Fixes discrepencies between idle and service latencies.
154162: sql: fix `COPY` with hidden and inaccessible columns r=mgartner a=mgartner
Fixes #119524
Release note (bug fix): A bug has been fixed that caused panics when
executing `COPY` into a table with hidden columns and expression
indexes. The panic only occurred when the
`expect_and_ignore_not_visible_columns_in_copy` setting was enabled.
This bug has been present since
`expect_and_ignore_not_visible_columns_in_copy` was introduced in
v22.1.0.
154201: external connection: deflake privs test r=jeffswenson a=msbutler
Informs #154141
Release note: none
154262: retry: deflake TestRetryWithMaxDurationAndMaxRetries r=jeffswenson a=jeffswenson
Previously, the time bound for the retry test was quite small. So an overloaded or slow test runner may hit the timeout before the goroutine was scheduled for max retries.
Fixes: #154160
Release note: none
Co-authored-by: Alyshan Jahani <alyshan@cockroachlabs.com>
Co-authored-by: Marcus Gartner <marcus@cockroachlabs.com>
Co-authored-by: Michael Butler <butler@cockroachlabs.com>
Co-authored-by: Jeff Swenson <jeffswenson@betterthannull.com>
File tree
8 files changed
+182
-246
lines changed- pkg
- ccl/cloudccl/externalconn/testdata
- sql
- pgwire/testdata/pgtest
- sessionphase
- sqlstats/sslocal
- util/retry
8 files changed
+182
-246
lines changedLines changed: 8 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
| 66 | + | |
67 | 67 | | |
68 | | - | |
69 | | - | |
70 | | - | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| |||
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
134 | | - | |
| 134 | + | |
135 | 135 | | |
136 | | - | |
137 | | - | |
138 | | - | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
| 138 | + | |
| 139 | + | |
138 | 140 | | |
139 | 141 | | |
140 | 142 | | |
| |||
178 | 180 | | |
179 | 181 | | |
180 | 182 | | |
| 183 | + | |
181 | 184 | | |
182 | 185 | | |
183 | 186 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
343 | 343 | | |
344 | 344 | | |
345 | 345 | | |
| 346 | + | |
346 | 347 | | |
347 | 348 | | |
348 | | - | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
349 | 355 | | |
350 | 356 | | |
351 | 357 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
199 | 199 | | |
200 | 200 | | |
201 | 201 | | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
202 | 248 | | |
203 | 249 | | |
204 | 250 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
117 | 120 | | |
118 | 121 | | |
119 | 122 | | |
| |||
0 commit comments