mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-04 23:45:07 +00:00
fix(crdb): obtain latest sequences when the tx is retried (#7795)
This commit is contained in:
parent
d337668599
commit
029a6d393a
@ -296,7 +296,7 @@ func (c *Commands) asyncPush(ctx context.Context, cmds ...eventstore.Command) {
|
||||
_, err := c.eventstore.Push(localCtx, cmds...)
|
||||
if err != nil {
|
||||
for _, cmd := range cmds {
|
||||
logging.WithError(err).Errorf("could not push event %q", cmd.Type())
|
||||
logging.WithError(err).Warnf("could not push event %q", cmd.Type())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user