From 34f6537c40317a53764209c671197ac61612378d Mon Sep 17 00:00:00 2001 From: Harshit Gangal Date: Tue, 23 Apr 2024 15:37:13 +0530 Subject: [PATCH] modify error message when transaction not found in numbered pool (#15760) Signed-off-by: Harshit Gangal --- go/pools/numbered.go | 2 +- go/pools/numbered_test.go | 2 +- go/vt/vttablet/tabletserver/stateful_connection_pool_test.go | 2 +- go/vt/vttablet/tabletserver/tabletserver_test.go | 2 +- go/vt/vttablet/tabletserver/tx_engine_test.go | 2 +- go/vt/vttablet/tabletserver/tx_executor_test.go | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go/pools/numbered.go b/go/pools/numbered.go index 8a50624f54c..304c723c3d2 100644 --- a/go/pools/numbered.go +++ b/go/pools/numbered.go @@ -108,7 +108,7 @@ func (nu *Numbered) Get(id int64, purpose string) (val any, err error) { if unreg, ok := nu.recentlyUnregistered.Get(fmt.Sprintf("%v", id)); ok { return nil, fmt.Errorf("ended at %v (%v)", unreg.timeUnregistered.Format("2006-01-02 15:04:05.000 MST"), unreg.reason) } - return nil, fmt.Errorf("not found") + return nil, fmt.Errorf("not found (potential transaction timeout)") } if nw.inUse { return nil, fmt.Errorf("in use: %s", nw.purpose) diff --git a/go/pools/numbered_test.go b/go/pools/numbered_test.go index 50be453c925..12bffdb8ad7 100644 --- a/go/pools/numbered_test.go +++ b/go/pools/numbered_test.go @@ -45,7 +45,7 @@ func TestNumberedGeneral(t *testing.T) { p.Put(id) _, err = p.Get(1, "test2") - assert.Contains(t, "not found", err.Error()) + assert.ErrorContains(t, err, "not found (potential transaction timeout)") p.Unregister(1, "test") // Should not fail p.Unregister(0, "test") // p is now empty diff --git a/go/vt/vttablet/tabletserver/stateful_connection_pool_test.go b/go/vt/vttablet/tabletserver/stateful_connection_pool_test.go index a84052f1d0f..b93c822cfdc 100644 --- a/go/vt/vttablet/tabletserver/stateful_connection_pool_test.go +++ b/go/vt/vttablet/tabletserver/stateful_connection_pool_test.go @@ -165,7 +165,7 @@ func TestActivePoolGetConnNonExistentTransaction(t *testing.T) { params := dbconfigs.New(db.ConnParams()) pool.Open(params, params, params) _, err := pool.GetAndLock(12345, "for query") - require.EqualError(t, err, "not found") + require.EqualError(t, err, "not found (potential transaction timeout)") } func TestExecWithAbortedCtx(t *testing.T) { diff --git a/go/vt/vttablet/tabletserver/tabletserver_test.go b/go/vt/vttablet/tabletserver/tabletserver_test.go index 0374fb416a6..3e546546485 100644 --- a/go/vt/vttablet/tabletserver/tabletserver_test.go +++ b/go/vt/vttablet/tabletserver/tabletserver_test.go @@ -497,7 +497,7 @@ func TestTabletServerCommiRollbacktFail(t *testing.T) { target := querypb.Target{TabletType: topodatapb.TabletType_PRIMARY} _, err := tsv.Commit(ctx, &target, -1) - want := "transaction -1: not found" + want := "transaction -1: not found (potential transaction timeout)" require.Equal(t, want, err.Error()) _, err = tsv.Rollback(ctx, &target, -1) require.Equal(t, want, err.Error()) diff --git a/go/vt/vttablet/tabletserver/tx_engine_test.go b/go/vt/vttablet/tabletserver/tx_engine_test.go index 7a97a8f331f..3c3a8a4eb4f 100644 --- a/go/vt/vttablet/tabletserver/tx_engine_test.go +++ b/go/vt/vttablet/tabletserver/tx_engine_test.go @@ -588,7 +588,7 @@ func TestTxEngineFailReserve(t *testing.T) { nonExistingID := int64(42) _, err = te.Reserve(ctx, options, nonExistingID, nil) - assert.EqualError(t, err, "transaction 42: not found") + assert.EqualError(t, err, "transaction 42: not found (potential transaction timeout)") txID, _, _, err := te.Begin(ctx, nil, 0, nil, options) require.NoError(t, err) diff --git a/go/vt/vttablet/tabletserver/tx_executor_test.go b/go/vt/vttablet/tabletserver/tx_executor_test.go index 2651eb2a6cc..c3949240147 100644 --- a/go/vt/vttablet/tabletserver/tx_executor_test.go +++ b/go/vt/vttablet/tabletserver/tx_executor_test.go @@ -78,7 +78,7 @@ func TestTxExecutorPrepareNotInTx(t *testing.T) { defer db.Close() defer tsv.StopService() err := txe.Prepare(0, "aa") - require.EqualError(t, err, "transaction 0: not found") + require.EqualError(t, err, "transaction 0: not found (potential transaction timeout)") } func TestTxExecutorPreparePoolFail(t *testing.T) {