mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 13:48:23 +00:00
fix(eventstore): use decimal, correct mirror (#9916)
# Eventstore fixes - `event.Position` used float64 before which can lead to [precision loss](https://github.com/golang/go/issues/47300). The type got replaced by [a type without precision loss](https://github.com/jackc/pgx-shopspring-decimal) - the handler reported the wrong error if the current state was updated and therefore took longer to retry failed events. # Mirror fixes - max age of auth requests can be configured to speed up copying data from `auth.auth_requests` table. Auth requests last updated before the set age will be ignored. Default is 1 month - notification projections are skipped because notifications should be sent by the source system. The projections are set to the latest position - ensure that mirror can be executed multiple times
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/jackc/pgx/v5/pgconn"
|
||||
"github.com/shopspring/decimal"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/api/authz"
|
||||
"github.com/zitadel/zitadel/internal/api/service"
|
||||
@@ -397,7 +398,7 @@ func (repo *testPusher) Push(_ context.Context, _ database.ContextQueryExecuter,
|
||||
|
||||
type testQuerier struct {
|
||||
events []Event
|
||||
sequence float64
|
||||
sequence decimal.Decimal
|
||||
instances []string
|
||||
err error
|
||||
t *testing.T
|
||||
@@ -430,9 +431,9 @@ func (repo *testQuerier) FilterToReducer(ctx context.Context, searchQuery *Searc
|
||||
return nil
|
||||
}
|
||||
|
||||
func (repo *testQuerier) LatestSequence(ctx context.Context, queryFactory *SearchQueryBuilder) (float64, error) {
|
||||
func (repo *testQuerier) LatestPosition(ctx context.Context, queryFactory *SearchQueryBuilder) (decimal.Decimal, error) {
|
||||
if repo.err != nil {
|
||||
return 0, repo.err
|
||||
return decimal.Decimal{}, repo.err
|
||||
}
|
||||
return repo.sequence, nil
|
||||
}
|
||||
@@ -1076,7 +1077,7 @@ func TestEventstore_FilterEvents(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestEventstore_LatestSequence(t *testing.T) {
|
||||
func TestEventstore_LatestPosition(t *testing.T) {
|
||||
type args struct {
|
||||
query *SearchQueryBuilder
|
||||
}
|
||||
@@ -1096,7 +1097,7 @@ func TestEventstore_LatestSequence(t *testing.T) {
|
||||
name: "no events",
|
||||
args: args{
|
||||
query: &SearchQueryBuilder{
|
||||
columns: ColumnsMaxSequence,
|
||||
columns: ColumnsMaxPosition,
|
||||
queries: []*SearchQuery{
|
||||
{
|
||||
builder: &SearchQueryBuilder{},
|
||||
@@ -1119,7 +1120,7 @@ func TestEventstore_LatestSequence(t *testing.T) {
|
||||
name: "repo error",
|
||||
args: args{
|
||||
query: &SearchQueryBuilder{
|
||||
columns: ColumnsMaxSequence,
|
||||
columns: ColumnsMaxPosition,
|
||||
queries: []*SearchQuery{
|
||||
{
|
||||
builder: &SearchQueryBuilder{},
|
||||
@@ -1142,7 +1143,7 @@ func TestEventstore_LatestSequence(t *testing.T) {
|
||||
name: "found events",
|
||||
args: args{
|
||||
query: &SearchQueryBuilder{
|
||||
columns: ColumnsMaxSequence,
|
||||
columns: ColumnsMaxPosition,
|
||||
queries: []*SearchQuery{
|
||||
{
|
||||
builder: &SearchQueryBuilder{},
|
||||
@@ -1168,7 +1169,7 @@ func TestEventstore_LatestSequence(t *testing.T) {
|
||||
querier: tt.fields.repo,
|
||||
}
|
||||
|
||||
_, err := es.LatestSequence(context.Background(), tt.args.query)
|
||||
_, err := es.LatestPosition(context.Background(), tt.args.query)
|
||||
if (err != nil) != tt.res.wantErr {
|
||||
t.Errorf("Eventstore.aggregatesToEvents() error = %v, wantErr %v", err, tt.res.wantErr)
|
||||
}
|
||||
|
Reference in New Issue
Block a user