sql, sqlstats: execution statistics count for explicit transactions are inflated #123692
Labels
C-bug
Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.
T-observability
We should investigate if setting up the instrumentation helper for
COMMIT TRANSACTION
statements is intentional. At the very least, the last sampled time is not being accurately tracked for these statements in the instrumentation helper setup, leading to incorrect execution statistics metrics for transactions.The last sampled time for a stmt is tracked in a map within the sql stats container (stmt fingerprint -> last sampled time). This map is updated at the time of sql stats recording. During instrumentation setup, we check the last sampled time to determine if this is the first time we're seeing this fingerprint, and sample the statement if so, however, we do not write any sql stats for
COMMIT TRANSACTION
statements.This leads to always sampling
COMMIT TRANSACTION
statements. A consequence of this is that we are also inflating the count of the execution_statistics for explicit transactions. At the time of recording transaction level stats, we check the value of instrumentationHelper.collectExecStats to record another entry of exec stats, which is now incorrectly represented to be for every execution of the transaction.Note: This behaviour may extend to other 'special case' statements other than COMMIT. Investigate to see if this is the case.
Jira issue: CRDB-38475
Epic CRDB-37544
The text was updated successfully, but these errors were encountered: