mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 21:17:32 +00:00
feat(eventstore): increase parallel write capabilities (#5940)
This implementation increases parallel write capabilities of the eventstore. Please have a look at the technical advisories: [05](https://zitadel.com/docs/support/advisory/a10005) and [06](https://zitadel.com/docs/support/advisory/a10006). The implementation of eventstore.push is rewritten and stored events are migrated to a new table `eventstore.events2`. If you are using cockroach: make sure that the database user of ZITADEL has `VIEWACTIVITY` grant. This is used to query events.
This commit is contained in:
@@ -14,6 +14,7 @@ import (
|
||||
"github.com/zitadel/zitadel/internal/database"
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
"github.com/zitadel/zitadel/internal/errors"
|
||||
"github.com/zitadel/zitadel/internal/eventstore/handler/v2"
|
||||
"github.com/zitadel/zitadel/internal/query/projection"
|
||||
"github.com/zitadel/zitadel/internal/telemetry/tracing"
|
||||
)
|
||||
@@ -40,23 +41,23 @@ type App struct {
|
||||
}
|
||||
|
||||
type OIDCApp struct {
|
||||
RedirectURIs database.StringArray
|
||||
ResponseTypes database.EnumArray[domain.OIDCResponseType]
|
||||
GrantTypes database.EnumArray[domain.OIDCGrantType]
|
||||
RedirectURIs database.TextArray[string]
|
||||
ResponseTypes database.Array[domain.OIDCResponseType]
|
||||
GrantTypes database.Array[domain.OIDCGrantType]
|
||||
AppType domain.OIDCApplicationType
|
||||
ClientID string
|
||||
AuthMethodType domain.OIDCAuthMethodType
|
||||
PostLogoutRedirectURIs database.StringArray
|
||||
PostLogoutRedirectURIs database.TextArray[string]
|
||||
Version domain.OIDCVersion
|
||||
ComplianceProblems database.StringArray
|
||||
ComplianceProblems database.TextArray[string]
|
||||
IsDevMode bool
|
||||
AccessTokenType domain.OIDCTokenType
|
||||
AssertAccessTokenRole bool
|
||||
AssertIDTokenRole bool
|
||||
AssertIDTokenUserinfo bool
|
||||
ClockSkew time.Duration
|
||||
AdditionalOrigins database.StringArray
|
||||
AllowedOrigins database.StringArray
|
||||
AdditionalOrigins database.TextArray[string]
|
||||
AllowedOrigins database.TextArray[string]
|
||||
SkipNativeAppSuccessPage bool
|
||||
}
|
||||
|
||||
@@ -253,7 +254,8 @@ func (q *Queries) AppByProjectAndAppID(ctx context.Context, shouldTriggerBulk bo
|
||||
defer func() { span.EndWithError(err) }()
|
||||
|
||||
if shouldTriggerBulk {
|
||||
ctx = projection.AppProjection.Trigger(ctx)
|
||||
ctx, err = projection.AppProjection.Trigger(ctx, handler.WithAwaitRunning())
|
||||
logging.OnError(err).Debug("trigger failed")
|
||||
}
|
||||
|
||||
stmt, scan := prepareAppQuery(ctx, q.client)
|
||||
@@ -502,7 +504,7 @@ func (q *Queries) SearchApps(ctx context.Context, queries *AppSearchQueries, wit
|
||||
if err != nil {
|
||||
return nil, errors.ThrowInternal(err, "QUERY-aJnZL", "Errors.Internal")
|
||||
}
|
||||
apps.LatestSequence, err = q.latestSequence(ctx, appsTable)
|
||||
apps.State, err = q.latestState(ctx, appsTable)
|
||||
return apps, err
|
||||
}
|
||||
|
||||
@@ -630,7 +632,7 @@ func prepareAppQuery(ctx context.Context, db prepareDatabase) (sq.SelectBuilder,
|
||||
if errs.Is(err, sql.ErrNoRows) {
|
||||
return nil, errors.ThrowNotFound(err, "QUERY-pCP8P", "Errors.App.NotExisting")
|
||||
}
|
||||
return nil, errors.ThrowInternal(err, "QUERY-0R2Nw", "Errors.Internal")
|
||||
return nil, errors.ThrowInternal(err, "QUERY-4SJlx", "Errors.Internal")
|
||||
}
|
||||
|
||||
apiConfig.set(app)
|
||||
@@ -700,7 +702,7 @@ func prepareProjectByAppQuery(ctx context.Context, db prepareDatabase) (sq.Selec
|
||||
)
|
||||
if err != nil {
|
||||
if errs.Is(err, sql.ErrNoRows) {
|
||||
return nil, errors.ThrowNotFound(err, "QUERY-fk2fs", "Errors.Project.NotFound")
|
||||
return nil, errors.ThrowNotFound(err, "QUERY-yxTMh", "Errors.Project.NotFound")
|
||||
}
|
||||
return nil, errors.ThrowInternal(err, "QUERY-dj2FF", "Errors.Internal")
|
||||
}
|
||||
@@ -802,7 +804,7 @@ func prepareAppsQuery(ctx context.Context, db prepareDatabase) (sq.SelectBuilder
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, errors.ThrowInternal(err, "QUERY-0R2Nw", "Errors.Internal")
|
||||
return nil, errors.ThrowInternal(err, "QUERY-XGWAX", "Errors.Internal")
|
||||
}
|
||||
|
||||
apiConfig.set(app)
|
||||
@@ -824,7 +826,7 @@ func prepareClientIDsQuery(ctx context.Context, db prepareDatabase) (sq.SelectBu
|
||||
LeftJoin(join(AppAPIConfigColumnAppID, AppColumnID)).
|
||||
LeftJoin(join(AppOIDCConfigColumnAppID, AppColumnID) + db.Timetravel(call.Took(ctx))).
|
||||
PlaceholderFormat(sq.Dollar), func(rows *sql.Rows) ([]string, error) {
|
||||
ids := database.StringArray{}
|
||||
ids := database.TextArray[string]{}
|
||||
|
||||
for rows.Next() {
|
||||
var apiID sql.NullString
|
||||
@@ -850,19 +852,19 @@ type sqlOIDCConfig struct {
|
||||
appID sql.NullString
|
||||
version sql.NullInt32
|
||||
clientID sql.NullString
|
||||
redirectUris database.StringArray
|
||||
redirectUris database.TextArray[string]
|
||||
applicationType sql.NullInt16
|
||||
authMethodType sql.NullInt16
|
||||
postLogoutRedirectUris database.StringArray
|
||||
postLogoutRedirectUris database.TextArray[string]
|
||||
devMode sql.NullBool
|
||||
accessTokenType sql.NullInt16
|
||||
accessTokenRoleAssertion sql.NullBool
|
||||
iDTokenRoleAssertion sql.NullBool
|
||||
iDTokenUserinfoAssertion sql.NullBool
|
||||
clockSkew sql.NullInt64
|
||||
additionalOrigins database.StringArray
|
||||
responseTypes database.EnumArray[domain.OIDCResponseType]
|
||||
grantTypes database.EnumArray[domain.OIDCGrantType]
|
||||
additionalOrigins database.TextArray[string]
|
||||
responseTypes database.Array[domain.OIDCResponseType]
|
||||
grantTypes database.Array[domain.OIDCGrantType]
|
||||
skipNativeAppSuccessPage sql.NullBool
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user