mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-28 23:18:54 +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:
@@ -10,7 +10,6 @@ import (
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
caos_errs "github.com/zitadel/zitadel/internal/errors"
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
"github.com/zitadel/zitadel/internal/eventstore/repository"
|
||||
"github.com/zitadel/zitadel/internal/eventstore/v1/models"
|
||||
"github.com/zitadel/zitadel/internal/repository/instance"
|
||||
"github.com/zitadel/zitadel/internal/repository/org"
|
||||
@@ -107,30 +106,26 @@ func TestCommandSide_AddLoginPolicy(t *testing.T) {
|
||||
t,
|
||||
expectFilter(),
|
||||
expectPush(
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
domain.PasswordlessTypeAllowed,
|
||||
"https://example.com/redirect",
|
||||
time.Hour*1,
|
||||
time.Hour*2,
|
||||
time.Hour*3,
|
||||
time.Hour*4,
|
||||
time.Hour*5,
|
||||
),
|
||||
),
|
||||
},
|
||||
org.NewLoginPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
domain.PasswordlessTypeAllowed,
|
||||
"https://example.com/redirect",
|
||||
time.Hour*1,
|
||||
time.Hour*2,
|
||||
time.Hour*3,
|
||||
time.Hour*4,
|
||||
time.Hour*5,
|
||||
),
|
||||
),
|
||||
),
|
||||
},
|
||||
@@ -205,42 +200,34 @@ func TestCommandSide_AddLoginPolicy(t *testing.T) {
|
||||
t,
|
||||
expectFilter(),
|
||||
expectPush(
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
domain.PasswordlessTypeAllowed,
|
||||
"https://example.com/redirect",
|
||||
time.Hour*1,
|
||||
time.Hour*2,
|
||||
time.Hour*3,
|
||||
time.Hour*4,
|
||||
time.Hour*5,
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicySecondFactorAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
domain.SecondFactorTypeTOTP,
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicyMultiFactorAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
domain.MultiFactorTypeU2FWithPIN,
|
||||
),
|
||||
),
|
||||
},
|
||||
org.NewLoginPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
domain.PasswordlessTypeAllowed,
|
||||
"https://example.com/redirect",
|
||||
time.Hour*1,
|
||||
time.Hour*2,
|
||||
time.Hour*3,
|
||||
time.Hour*4,
|
||||
time.Hour*5,
|
||||
),
|
||||
org.NewLoginPolicySecondFactorAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
domain.SecondFactorTypeTOTP,
|
||||
),
|
||||
org.NewLoginPolicyMultiFactorAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
domain.MultiFactorTypeU2FWithPIN,
|
||||
),
|
||||
),
|
||||
),
|
||||
},
|
||||
@@ -336,37 +323,31 @@ func TestCommandSide_AddLoginPolicy(t *testing.T) {
|
||||
),
|
||||
),
|
||||
expectPush(
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
domain.PasswordlessTypeAllowed,
|
||||
"https://example.com/redirect",
|
||||
time.Hour*1,
|
||||
time.Hour*2,
|
||||
time.Hour*3,
|
||||
time.Hour*4,
|
||||
time.Hour*5,
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewIdentityProviderAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"config1",
|
||||
domain.IdentityProviderTypeSystem,
|
||||
),
|
||||
),
|
||||
},
|
||||
org.NewLoginPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
domain.PasswordlessTypeAllowed,
|
||||
"https://example.com/redirect",
|
||||
time.Hour*1,
|
||||
time.Hour*2,
|
||||
time.Hour*3,
|
||||
time.Hour*4,
|
||||
time.Hour*5,
|
||||
),
|
||||
org.NewIdentityProviderAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"config1",
|
||||
domain.IdentityProviderTypeSystem,
|
||||
),
|
||||
),
|
||||
),
|
||||
},
|
||||
@@ -561,30 +542,26 @@ func TestCommandSide_ChangeLoginPolicy(t *testing.T) {
|
||||
),
|
||||
),
|
||||
expectPush(
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
newLoginPolicyChangedEvent(context.Background(),
|
||||
"org1",
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
domain.PasswordlessTypeNotAllowed,
|
||||
"",
|
||||
&duration10,
|
||||
&duration20,
|
||||
&duration30,
|
||||
&duration40,
|
||||
&duration50,
|
||||
),
|
||||
),
|
||||
},
|
||||
newLoginPolicyChangedEvent(context.Background(),
|
||||
"org1",
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
domain.PasswordlessTypeNotAllowed,
|
||||
"",
|
||||
&duration10,
|
||||
&duration20,
|
||||
&duration30,
|
||||
&duration40,
|
||||
&duration50,
|
||||
),
|
||||
),
|
||||
),
|
||||
},
|
||||
@@ -714,12 +691,8 @@ func TestCommandSide_RemoveLoginPolicy(t *testing.T) {
|
||||
),
|
||||
),
|
||||
expectPush(
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicyRemovedEvent(context.Background(),
|
||||
&org.NewAggregate("org1").Aggregate),
|
||||
),
|
||||
},
|
||||
org.NewLoginPolicyRemovedEvent(context.Background(),
|
||||
&org.NewAggregate("org1").Aggregate),
|
||||
),
|
||||
),
|
||||
},
|
||||
@@ -981,14 +954,10 @@ func TestCommandSide_AddIDPProviderLoginPolicy(t *testing.T) {
|
||||
),
|
||||
expectFilter(),
|
||||
expectPush(
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewIdentityProviderAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"config1",
|
||||
domain.IdentityProviderTypeOrg),
|
||||
),
|
||||
},
|
||||
org.NewIdentityProviderAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"config1",
|
||||
domain.IdentityProviderTypeOrg),
|
||||
),
|
||||
),
|
||||
},
|
||||
@@ -1247,13 +1216,9 @@ func TestCommandSide_RemoveIDPProviderLoginPolicy(t *testing.T) {
|
||||
),
|
||||
),
|
||||
expectPush(
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewIdentityProviderRemovedEvent(context.Background(),
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"config1"),
|
||||
),
|
||||
},
|
||||
org.NewIdentityProviderRemovedEvent(context.Background(),
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"config1"),
|
||||
),
|
||||
),
|
||||
},
|
||||
@@ -1311,13 +1276,9 @@ func TestCommandSide_RemoveIDPProviderLoginPolicy(t *testing.T) {
|
||||
),
|
||||
),
|
||||
expectPush(
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewIdentityProviderRemovedEvent(context.Background(),
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"config1"),
|
||||
),
|
||||
},
|
||||
org.NewIdentityProviderRemovedEvent(context.Background(),
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"config1"),
|
||||
),
|
||||
),
|
||||
},
|
||||
@@ -1390,18 +1351,14 @@ func TestCommandSide_RemoveIDPProviderLoginPolicy(t *testing.T) {
|
||||
),
|
||||
),
|
||||
expectPush(
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewIdentityProviderRemovedEvent(context.Background(),
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"config1"),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
user.NewUserIDPLinkCascadeRemovedEvent(context.Background(),
|
||||
&user.NewAggregate("user1", "org1").Aggregate,
|
||||
"config1", "externaluser1")),
|
||||
},
|
||||
uniqueConstraintsFromEventConstraint(user.NewRemoveUserIDPLinkUniqueConstraint("config1", "externaluser1")),
|
||||
org.NewIdentityProviderRemovedEvent(context.Background(),
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"config1",
|
||||
),
|
||||
user.NewUserIDPLinkCascadeRemovedEvent(context.Background(),
|
||||
&user.NewAggregate("user1", "org1").Aggregate,
|
||||
"config1", "externaluser1",
|
||||
),
|
||||
),
|
||||
),
|
||||
},
|
||||
@@ -1527,13 +1484,9 @@ func TestCommandSide_AddSecondFactorLoginPolicy(t *testing.T) {
|
||||
t,
|
||||
expectFilter(),
|
||||
expectPush(
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicySecondFactorAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
domain.SecondFactorTypeTOTP),
|
||||
),
|
||||
},
|
||||
org.NewLoginPolicySecondFactorAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
domain.SecondFactorTypeTOTP),
|
||||
),
|
||||
),
|
||||
},
|
||||
@@ -1553,13 +1506,9 @@ func TestCommandSide_AddSecondFactorLoginPolicy(t *testing.T) {
|
||||
t,
|
||||
expectFilter(),
|
||||
expectPush(
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicySecondFactorAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
domain.SecondFactorTypeOTPEmail),
|
||||
),
|
||||
},
|
||||
org.NewLoginPolicySecondFactorAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
domain.SecondFactorTypeOTPEmail),
|
||||
),
|
||||
),
|
||||
},
|
||||
@@ -1579,13 +1528,9 @@ func TestCommandSide_AddSecondFactorLoginPolicy(t *testing.T) {
|
||||
t,
|
||||
expectFilter(),
|
||||
expectPush(
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicySecondFactorAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
domain.SecondFactorTypeOTPSMS),
|
||||
),
|
||||
},
|
||||
org.NewLoginPolicySecondFactorAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
domain.SecondFactorTypeOTPSMS),
|
||||
),
|
||||
),
|
||||
},
|
||||
@@ -1612,13 +1557,9 @@ func TestCommandSide_AddSecondFactorLoginPolicy(t *testing.T) {
|
||||
),
|
||||
),
|
||||
expectPush(
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicySecondFactorAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
domain.SecondFactorTypeOTPSMS),
|
||||
),
|
||||
},
|
||||
org.NewLoginPolicySecondFactorAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
domain.SecondFactorTypeOTPSMS),
|
||||
),
|
||||
),
|
||||
},
|
||||
@@ -1821,13 +1762,9 @@ func TestCommandSide_RemoveSecondFactoroginPolicy(t *testing.T) {
|
||||
),
|
||||
),
|
||||
expectPush(
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicySecondFactorRemovedEvent(context.Background(),
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
domain.SecondFactorTypeTOTP),
|
||||
),
|
||||
},
|
||||
org.NewLoginPolicySecondFactorRemovedEvent(context.Background(),
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
domain.SecondFactorTypeTOTP),
|
||||
),
|
||||
),
|
||||
},
|
||||
@@ -1856,13 +1793,9 @@ func TestCommandSide_RemoveSecondFactoroginPolicy(t *testing.T) {
|
||||
),
|
||||
),
|
||||
expectPush(
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicySecondFactorRemovedEvent(context.Background(),
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
domain.SecondFactorTypeOTPEmail),
|
||||
),
|
||||
},
|
||||
org.NewLoginPolicySecondFactorRemovedEvent(context.Background(),
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
domain.SecondFactorTypeOTPEmail),
|
||||
),
|
||||
),
|
||||
},
|
||||
@@ -1891,13 +1824,9 @@ func TestCommandSide_RemoveSecondFactoroginPolicy(t *testing.T) {
|
||||
),
|
||||
),
|
||||
expectPush(
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicySecondFactorRemovedEvent(context.Background(),
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
domain.SecondFactorTypeOTPSMS),
|
||||
),
|
||||
},
|
||||
org.NewLoginPolicySecondFactorRemovedEvent(context.Background(),
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
domain.SecondFactorTypeOTPSMS),
|
||||
),
|
||||
),
|
||||
},
|
||||
@@ -2009,13 +1938,9 @@ func TestCommandSide_AddMultiFactorLoginPolicy(t *testing.T) {
|
||||
t,
|
||||
expectFilter(),
|
||||
expectPush(
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicyMultiFactorAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
domain.MultiFactorTypeU2FWithPIN),
|
||||
),
|
||||
},
|
||||
org.NewLoginPolicyMultiFactorAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
domain.MultiFactorTypeU2FWithPIN),
|
||||
),
|
||||
),
|
||||
},
|
||||
@@ -2158,13 +2083,9 @@ func TestCommandSide_RemoveMultiFactorLoginPolicy(t *testing.T) {
|
||||
),
|
||||
),
|
||||
expectPush(
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicyMultiFactorRemovedEvent(context.Background(),
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
domain.MultiFactorTypeU2FWithPIN),
|
||||
),
|
||||
},
|
||||
org.NewLoginPolicyMultiFactorRemovedEvent(context.Background(),
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
domain.MultiFactorTypeU2FWithPIN),
|
||||
),
|
||||
),
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user