mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 18:33:28 +00:00
fix(crdb): obtain latest sequences when the tx is retried (#7795)
This commit is contained in:
@@ -390,10 +390,10 @@ func TestCRDB_Push_Parallel(t *testing.T) {
|
||||
},
|
||||
},
|
||||
res: res{
|
||||
minErrCount: 1,
|
||||
minErrCount: 0,
|
||||
eventsRes: eventsRes{
|
||||
aggIDs: []string{"204"},
|
||||
pushedEventsCount: 6,
|
||||
pushedEventsCount: 8,
|
||||
aggTypes: database.TextArray[eventstore.AggregateType]{eventstore.AggregateType(t.Name())},
|
||||
},
|
||||
},
|
||||
|
@@ -8,7 +8,6 @@ import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/cockroachdb/cockroach-go/v2/crdb"
|
||||
"github.com/jackc/pgx/v5/pgconn"
|
||||
@@ -29,13 +28,10 @@ func (es *Eventstore) Push(ctx context.Context, commands ...eventstore.Command)
|
||||
// tx is not closed because [crdb.ExecuteInTx] takes care of that
|
||||
var (
|
||||
sequences []*latestSequence
|
||||
once sync.Once
|
||||
)
|
||||
|
||||
err = crdb.ExecuteInTx(ctx, &transaction{tx}, func() error {
|
||||
once.Do(func() {
|
||||
sequences, err = latestSequences(ctx, tx, commands)
|
||||
})
|
||||
sequences, err = latestSequences(ctx, tx, commands)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
Reference in New Issue
Block a user