Skip to content

Commit

Permalink
modify error message when transaction not found in numbered pool (#15760
Browse files Browse the repository at this point in the history
)

Signed-off-by: Harshit Gangal <[email protected]>
  • Loading branch information
harshit-gangal authored Apr 23, 2024
1 parent 5e2a873 commit 34f6537
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion go/pools/numbered.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion go/pools/numbered_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion go/vt/vttablet/tabletserver/tabletserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
2 changes: 1 addition & 1 deletion go/vt/vttablet/tabletserver/tx_engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion go/vt/vttablet/tabletserver/tx_executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 34f6537

Please sign in to comment.