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:
Silvan
2023-10-19 12:19:10 +02:00
committed by GitHub
parent 259faba3f0
commit b5564572bc
791 changed files with 30326 additions and 43202 deletions

View File

@@ -4,16 +4,15 @@ import (
"context"
"testing"
"github.com/stretchr/testify/assert"
"github.com/zitadel/zitadel/internal/api/authz"
"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/notification/channels/fs"
"github.com/zitadel/zitadel/internal/repository/instance"
"github.com/zitadel/zitadel/internal/repository/settings"
"github.com/stretchr/testify/assert"
)
func TestCommandSide_AddDefaultDebugNotificationProviderLog(t *testing.T) {
@@ -28,6 +27,7 @@ func TestCommandSide_AddDefaultDebugNotificationProviderLog(t *testing.T) {
want *domain.ObjectDetails
err func(error) bool
}
ctx := authz.WithInstanceID(context.Background(), "INSTANCE")
tests := []struct {
name string
fields fields
@@ -42,7 +42,7 @@ func TestCommandSide_AddDefaultDebugNotificationProviderLog(t *testing.T) {
expectFilter(
eventFromEventPusherWithInstanceID(
"INSTANCE",
instance.NewDebugNotificationProviderLogAddedEvent(context.Background(),
instance.NewDebugNotificationProviderLogAddedEvent(ctx,
&instance.NewAggregate("INSTANCE").Aggregate,
true,
),
@@ -51,7 +51,7 @@ func TestCommandSide_AddDefaultDebugNotificationProviderLog(t *testing.T) {
),
},
args: args{
ctx: authz.WithInstanceID(context.Background(), "INSTANCE"),
ctx: authz.WithInstanceID(ctx, "INSTANCE"),
provider: &fs.Config{
Compact: true,
Enabled: true,
@@ -68,20 +68,15 @@ func TestCommandSide_AddDefaultDebugNotificationProviderLog(t *testing.T) {
t,
expectFilter(),
expectPush(
[]*repository.Event{
eventFromEventPusherWithInstanceID(
"INSTANCE",
instance.NewDebugNotificationProviderLogAddedEvent(context.Background(),
&instance.NewAggregate("INSTANCE").Aggregate,
true,
),
),
},
instance.NewDebugNotificationProviderLogAddedEvent(ctx,
&instance.NewAggregate("INSTANCE").Aggregate,
true,
),
),
),
},
args: args{
ctx: authz.WithInstanceID(context.Background(), "INSTANCE"),
ctx: authz.WithInstanceID(ctx, "INSTANCE"),
provider: &fs.Config{
Compact: true,
},
@@ -99,20 +94,15 @@ func TestCommandSide_AddDefaultDebugNotificationProviderLog(t *testing.T) {
t,
expectFilter(),
expectPush(
[]*repository.Event{
eventFromEventPusherWithInstanceID(
"INSTANCE",
instance.NewDebugNotificationProviderLogAddedEvent(context.Background(),
&instance.NewAggregate("INSTANCE").Aggregate,
true,
),
),
},
instance.NewDebugNotificationProviderLogAddedEvent(ctx,
&instance.NewAggregate("INSTANCE").Aggregate,
true,
),
),
),
},
args: args{
ctx: authz.WithInstanceID(context.Background(), "INSTANCE"),
ctx: authz.WithInstanceID(ctx, "INSTANCE"),
provider: &fs.Config{
Compact: true,
Enabled: true,
@@ -156,6 +146,7 @@ func TestCommandSide_ChangeDebugNotificationProviderLog(t *testing.T) {
want *domain.ObjectDetails
err func(error) bool
}
ctx := authz.WithInstanceID(context.Background(), "INSTANCE")
tests := []struct {
name string
fields fields
@@ -171,7 +162,7 @@ func TestCommandSide_ChangeDebugNotificationProviderLog(t *testing.T) {
),
},
args: args{
ctx: context.Background(),
ctx: ctx,
provider: &fs.Config{
Compact: true,
Enabled: true,
@@ -188,7 +179,7 @@ func TestCommandSide_ChangeDebugNotificationProviderLog(t *testing.T) {
t,
expectFilter(
eventFromEventPusher(
instance.NewDebugNotificationProviderLogAddedEvent(context.Background(),
instance.NewDebugNotificationProviderLogAddedEvent(ctx,
&instance.NewAggregate("INSTANCE").Aggregate,
true,
),
@@ -197,7 +188,7 @@ func TestCommandSide_ChangeDebugNotificationProviderLog(t *testing.T) {
),
},
args: args{
ctx: context.Background(),
ctx: ctx,
provider: &fs.Config{
Compact: true,
Enabled: false,
@@ -215,25 +206,20 @@ func TestCommandSide_ChangeDebugNotificationProviderLog(t *testing.T) {
expectFilter(
eventFromEventPusherWithInstanceID(
"INSTANCE",
instance.NewDebugNotificationProviderLogAddedEvent(context.Background(),
instance.NewDebugNotificationProviderLogAddedEvent(ctx,
&instance.NewAggregate("INSTANCE").Aggregate,
true,
),
),
),
expectPush(
[]*repository.Event{
eventFromEventPusherWithInstanceID(
"INSTANCE",
newDefaultDebugNotificationLogChangedEvent(context.Background(),
false),
),
},
newDefaultDebugNotificationLogChangedEvent(ctx,
false),
),
),
},
args: args{
ctx: authz.WithInstanceID(context.Background(), "INSTANCE"),
ctx: authz.WithInstanceID(ctx, "INSTANCE"),
provider: &fs.Config{
Compact: false,
Enabled: false,
@@ -252,25 +238,20 @@ func TestCommandSide_ChangeDebugNotificationProviderLog(t *testing.T) {
t,
expectFilter(
eventFromEventPusher(
instance.NewDebugNotificationProviderLogAddedEvent(context.Background(),
instance.NewDebugNotificationProviderLogAddedEvent(ctx,
&instance.NewAggregate("INSTANCE").Aggregate,
true,
),
),
),
expectPush(
[]*repository.Event{
eventFromEventPusherWithInstanceID(
"INSTANCE",
newDefaultDebugNotificationLogChangedEvent(context.Background(),
false),
),
},
newDefaultDebugNotificationLogChangedEvent(ctx,
false),
),
),
},
args: args{
ctx: authz.WithInstanceID(context.Background(), "INSTANCE"),
ctx: authz.WithInstanceID(ctx, "INSTANCE"),
provider: &fs.Config{
Compact: false,
Enabled: true,
@@ -313,6 +294,7 @@ func TestCommandSide_RemoveDebugNotificationProviderLog(t *testing.T) {
want *domain.ObjectDetails
err func(error) bool
}
ctx := authz.WithInstanceID(context.Background(), "INSTANCE")
tests := []struct {
name string
fields fields
@@ -328,7 +310,7 @@ func TestCommandSide_RemoveDebugNotificationProviderLog(t *testing.T) {
),
},
args: args{
ctx: context.Background(),
ctx: ctx,
},
res: res{
err: caos_errs.IsNotFound,
@@ -342,25 +324,20 @@ func TestCommandSide_RemoveDebugNotificationProviderLog(t *testing.T) {
expectFilter(
eventFromEventPusherWithInstanceID(
"INSTANCE",
instance.NewDebugNotificationProviderLogAddedEvent(context.Background(),
instance.NewDebugNotificationProviderLogAddedEvent(ctx,
&instance.NewAggregate("INSTANCE").Aggregate,
true,
),
),
),
expectPush(
[]*repository.Event{
eventFromEventPusherWithInstanceID(
"INSTANCE",
instance.NewDebugNotificationProviderLogRemovedEvent(context.Background(),
&instance.NewAggregate("INSTANCE").Aggregate),
),
},
instance.NewDebugNotificationProviderLogRemovedEvent(ctx,
&instance.NewAggregate("INSTANCE").Aggregate),
),
),
},
args: args{
ctx: authz.WithInstanceID(context.Background(), "INSTANCE"),
ctx: authz.WithInstanceID(ctx, "INSTANCE"),
},
res: res{
want: &domain.ObjectDetails{