test: verify transaction retry metric in mysql integration
This commit is contained in:
@@ -33,6 +33,7 @@ func TestIntegrationWithTxRetriesPreCommitDeadlock(t *testing.T) {
|
||||
if _, err := db.ExecContext(ctx, "INSERT INTO orbit_test_tx_retry(id,value) VALUES (1,0),(2,0)"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
beforeStats := ReadTransactionStats()
|
||||
|
||||
var barrier sync.WaitGroup
|
||||
barrier.Add(2)
|
||||
@@ -71,6 +72,10 @@ func TestIntegrationWithTxRetriesPreCommitDeadlock(t *testing.T) {
|
||||
if callbackCalls.Load() < 3 {
|
||||
t.Fatalf("deadlock did not cause a bounded pre-commit retry; callback calls=%d", callbackCalls.Load())
|
||||
}
|
||||
afterStats := ReadTransactionStats()
|
||||
if afterStats.Retries <= beforeStats.Retries {
|
||||
t.Fatalf("transaction retry metric did not advance: before=%+v after=%+v", beforeStats, afterStats)
|
||||
}
|
||||
var value int
|
||||
if err := db.QueryRowContext(ctx, "SELECT COALESCE(MIN(value),0) FROM orbit_test_tx_retry").Scan(&value); err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -78,5 +83,5 @@ func TestIntegrationWithTxRetriesPreCommitDeadlock(t *testing.T) {
|
||||
if value != 2 {
|
||||
t.Fatalf("committed value=%d want 2", value)
|
||||
}
|
||||
t.Logf("pre-commit deadlock recovered with %d callback attempts and two committed transactions", callbackCalls.Load())
|
||||
t.Logf("pre-commit deadlock recovered with %d callback attempts and transaction retry metric %+v", callbackCalls.Load(), afterStats)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user