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:
@@ -6,8 +6,7 @@ import (
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
"github.com/zitadel/zitadel/internal/errors"
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
"github.com/zitadel/zitadel/internal/eventstore/handler"
|
||||
"github.com/zitadel/zitadel/internal/eventstore/repository"
|
||||
"github.com/zitadel/zitadel/internal/eventstore/handler/v2"
|
||||
"github.com/zitadel/zitadel/internal/repository/instance"
|
||||
"github.com/zitadel/zitadel/internal/repository/org"
|
||||
)
|
||||
@@ -25,22 +24,22 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
{
|
||||
name: "org reduceAdded Title",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.CustomTextSetEventType),
|
||||
org.AggregateType,
|
||||
[]byte(`{
|
||||
event: getEvent(
|
||||
testEvent(
|
||||
org.CustomTextSetEventType,
|
||||
org.AggregateType,
|
||||
[]byte(`{
|
||||
"key": "Title",
|
||||
"language": "en",
|
||||
"template": "InitCode",
|
||||
"text": "Test"
|
||||
}`),
|
||||
), org.CustomTextSetEventMapper),
|
||||
), org.CustomTextSetEventMapper),
|
||||
},
|
||||
reduce: (&messageTextProjection{}).reduceAdded,
|
||||
want: wantReduce{
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
@@ -64,22 +63,22 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
{
|
||||
name: "org reduceAdded PreHeader",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.CustomTextSetEventType),
|
||||
org.AggregateType,
|
||||
[]byte(`{
|
||||
event: getEvent(
|
||||
testEvent(
|
||||
org.CustomTextSetEventType,
|
||||
org.AggregateType,
|
||||
[]byte(`{
|
||||
"key": "PreHeader",
|
||||
"language": "en",
|
||||
"template": "InitCode",
|
||||
"text": "Test"
|
||||
}`),
|
||||
), org.CustomTextSetEventMapper),
|
||||
), org.CustomTextSetEventMapper),
|
||||
},
|
||||
reduce: (&messageTextProjection{}).reduceAdded,
|
||||
want: wantReduce{
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
@@ -103,22 +102,22 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
{
|
||||
name: "org reduceAdded Subject",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.CustomTextSetEventType),
|
||||
org.AggregateType,
|
||||
[]byte(`{
|
||||
event: getEvent(
|
||||
testEvent(
|
||||
org.CustomTextSetEventType,
|
||||
org.AggregateType,
|
||||
[]byte(`{
|
||||
"key": "Subject",
|
||||
"language": "en",
|
||||
"template": "InitCode",
|
||||
"text": "Test"
|
||||
}`),
|
||||
), org.CustomTextSetEventMapper),
|
||||
), org.CustomTextSetEventMapper),
|
||||
},
|
||||
reduce: (&messageTextProjection{}).reduceAdded,
|
||||
want: wantReduce{
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
@@ -142,22 +141,22 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
{
|
||||
name: "org reduceAdded Greeting",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.CustomTextSetEventType),
|
||||
org.AggregateType,
|
||||
[]byte(`{
|
||||
event: getEvent(
|
||||
testEvent(
|
||||
org.CustomTextSetEventType,
|
||||
org.AggregateType,
|
||||
[]byte(`{
|
||||
"key": "Greeting",
|
||||
"language": "en",
|
||||
"template": "InitCode",
|
||||
"text": "Test"
|
||||
}`),
|
||||
), org.CustomTextSetEventMapper),
|
||||
), org.CustomTextSetEventMapper),
|
||||
},
|
||||
reduce: (&messageTextProjection{}).reduceAdded,
|
||||
want: wantReduce{
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
@@ -181,22 +180,22 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
{
|
||||
name: "org reduceAdded Text",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.CustomTextSetEventType),
|
||||
org.AggregateType,
|
||||
[]byte(`{
|
||||
event: getEvent(
|
||||
testEvent(
|
||||
org.CustomTextSetEventType,
|
||||
org.AggregateType,
|
||||
[]byte(`{
|
||||
"key": "Text",
|
||||
"language": "en",
|
||||
"template": "InitCode",
|
||||
"text": "Test"
|
||||
}`),
|
||||
), org.CustomTextSetEventMapper),
|
||||
), org.CustomTextSetEventMapper),
|
||||
},
|
||||
reduce: (&messageTextProjection{}).reduceAdded,
|
||||
want: wantReduce{
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
@@ -220,22 +219,22 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
{
|
||||
name: "org reduceAdded ButtonText",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.CustomTextSetEventType),
|
||||
org.AggregateType,
|
||||
[]byte(`{
|
||||
event: getEvent(
|
||||
testEvent(
|
||||
org.CustomTextSetEventType,
|
||||
org.AggregateType,
|
||||
[]byte(`{
|
||||
"key": "ButtonText",
|
||||
"language": "en",
|
||||
"template": "InitCode",
|
||||
"text": "Test"
|
||||
}`),
|
||||
), org.CustomTextSetEventMapper),
|
||||
), org.CustomTextSetEventMapper),
|
||||
},
|
||||
reduce: (&messageTextProjection{}).reduceAdded,
|
||||
want: wantReduce{
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
@@ -259,22 +258,22 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
{
|
||||
name: "org reduceAdded Footer",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.CustomTextSetEventType),
|
||||
org.AggregateType,
|
||||
[]byte(`{
|
||||
event: getEvent(
|
||||
testEvent(
|
||||
org.CustomTextSetEventType,
|
||||
org.AggregateType,
|
||||
[]byte(`{
|
||||
"key": "Footer",
|
||||
"language": "en",
|
||||
"template": "InitCode",
|
||||
"text": "Test"
|
||||
}`),
|
||||
), org.CustomTextSetEventMapper),
|
||||
), org.CustomTextSetEventMapper),
|
||||
},
|
||||
reduce: (&messageTextProjection{}).reduceAdded,
|
||||
want: wantReduce{
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
@@ -298,21 +297,21 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
{
|
||||
name: "org reduceRemoved Title",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.CustomTextRemovedEventType),
|
||||
org.AggregateType,
|
||||
[]byte(`{
|
||||
event: getEvent(
|
||||
testEvent(
|
||||
org.CustomTextRemovedEventType,
|
||||
org.AggregateType,
|
||||
[]byte(`{
|
||||
"key": "Title",
|
||||
"language": "en",
|
||||
"template": "InitCode"
|
||||
}`),
|
||||
), org.CustomTextRemovedEventMapper),
|
||||
), org.CustomTextRemovedEventMapper),
|
||||
},
|
||||
reduce: (&messageTextProjection{}).reduceRemoved,
|
||||
want: wantReduce{
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
@@ -334,17 +333,17 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
{
|
||||
name: "instance reduceInstanceRemoved",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.InstanceRemovedEventType),
|
||||
instance.AggregateType,
|
||||
nil,
|
||||
), instance.InstanceRemovedEventMapper),
|
||||
event: getEvent(
|
||||
testEvent(
|
||||
instance.InstanceRemovedEventType,
|
||||
instance.AggregateType,
|
||||
nil,
|
||||
), instance.InstanceRemovedEventMapper),
|
||||
},
|
||||
reduce: reduceInstanceRemovedHelper(MessageTextInstanceIDCol),
|
||||
want: wantReduce{
|
||||
aggregateType: eventstore.AggregateType("instance"),
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
aggregateType: eventstore.AggregateType("instance"),
|
||||
sequence: 15,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
@@ -360,21 +359,21 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
{
|
||||
name: "org reduceRemoved PreHeader",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.CustomTextRemovedEventType),
|
||||
org.AggregateType,
|
||||
[]byte(`{
|
||||
event: getEvent(
|
||||
testEvent(
|
||||
org.CustomTextRemovedEventType,
|
||||
org.AggregateType,
|
||||
[]byte(`{
|
||||
"key": "PreHeader",
|
||||
"language": "en",
|
||||
"template": "InitCode"
|
||||
}`),
|
||||
), org.CustomTextRemovedEventMapper),
|
||||
), org.CustomTextRemovedEventMapper),
|
||||
},
|
||||
reduce: (&messageTextProjection{}).reduceRemoved,
|
||||
want: wantReduce{
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
@@ -396,21 +395,21 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
{
|
||||
name: "org reduceRemoved Subject",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.CustomTextRemovedEventType),
|
||||
org.AggregateType,
|
||||
[]byte(`{
|
||||
event: getEvent(
|
||||
testEvent(
|
||||
org.CustomTextRemovedEventType,
|
||||
org.AggregateType,
|
||||
[]byte(`{
|
||||
"key": "Subject",
|
||||
"language": "en",
|
||||
"template": "InitCode"
|
||||
}`),
|
||||
), org.CustomTextRemovedEventMapper),
|
||||
), org.CustomTextRemovedEventMapper),
|
||||
},
|
||||
reduce: (&messageTextProjection{}).reduceRemoved,
|
||||
want: wantReduce{
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
@@ -432,21 +431,21 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
{
|
||||
name: "org reduceRemoved Greeting",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.CustomTextRemovedEventType),
|
||||
org.AggregateType,
|
||||
[]byte(`{
|
||||
event: getEvent(
|
||||
testEvent(
|
||||
org.CustomTextRemovedEventType,
|
||||
org.AggregateType,
|
||||
[]byte(`{
|
||||
"key": "Greeting",
|
||||
"language": "en",
|
||||
"template": "InitCode"
|
||||
}`),
|
||||
), org.CustomTextRemovedEventMapper),
|
||||
), org.CustomTextRemovedEventMapper),
|
||||
},
|
||||
reduce: (&messageTextProjection{}).reduceRemoved,
|
||||
want: wantReduce{
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
@@ -468,21 +467,21 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
{
|
||||
name: "org reduceRemoved Text",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.CustomTextRemovedEventType),
|
||||
org.AggregateType,
|
||||
[]byte(`{
|
||||
event: getEvent(
|
||||
testEvent(
|
||||
org.CustomTextRemovedEventType,
|
||||
org.AggregateType,
|
||||
[]byte(`{
|
||||
"key": "Text",
|
||||
"language": "en",
|
||||
"template": "InitCode"
|
||||
}`),
|
||||
), org.CustomTextRemovedEventMapper),
|
||||
), org.CustomTextRemovedEventMapper),
|
||||
},
|
||||
reduce: (&messageTextProjection{}).reduceRemoved,
|
||||
want: wantReduce{
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
@@ -504,21 +503,21 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
{
|
||||
name: "org reduceRemoved ButtonText",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.CustomTextRemovedEventType),
|
||||
org.AggregateType,
|
||||
[]byte(`{
|
||||
event: getEvent(
|
||||
testEvent(
|
||||
org.CustomTextRemovedEventType,
|
||||
org.AggregateType,
|
||||
[]byte(`{
|
||||
"key": "ButtonText",
|
||||
"language": "en",
|
||||
"template": "InitCode"
|
||||
}`),
|
||||
), org.CustomTextRemovedEventMapper),
|
||||
), org.CustomTextRemovedEventMapper),
|
||||
},
|
||||
reduce: (&messageTextProjection{}).reduceRemoved,
|
||||
want: wantReduce{
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
@@ -540,21 +539,21 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
{
|
||||
name: "org reduceRemoved Footer",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.CustomTextRemovedEventType),
|
||||
org.AggregateType,
|
||||
[]byte(`{
|
||||
event: getEvent(
|
||||
testEvent(
|
||||
org.CustomTextRemovedEventType,
|
||||
org.AggregateType,
|
||||
[]byte(`{
|
||||
"key": "Footer",
|
||||
"language": "en",
|
||||
"template": "InitCode"
|
||||
}`),
|
||||
), org.CustomTextRemovedEventMapper),
|
||||
), org.CustomTextRemovedEventMapper),
|
||||
},
|
||||
reduce: (&messageTextProjection{}).reduceRemoved,
|
||||
want: wantReduce{
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
@@ -577,20 +576,20 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
name: "org reduceRemoved",
|
||||
reduce: (&messageTextProjection{}).reduceTemplateRemoved,
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.CustomTextTemplateRemovedEventType),
|
||||
org.AggregateType,
|
||||
[]byte(`{
|
||||
event: getEvent(
|
||||
testEvent(
|
||||
org.CustomTextTemplateRemovedEventType,
|
||||
org.AggregateType,
|
||||
[]byte(`{
|
||||
"key": "Title",
|
||||
"language": "en",
|
||||
"template": "InitCode"
|
||||
}`),
|
||||
), org.CustomTextTemplateRemovedEventMapper),
|
||||
), org.CustomTextTemplateRemovedEventMapper),
|
||||
},
|
||||
want: wantReduce{
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
@@ -610,21 +609,21 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
name: "instance reduceAdded",
|
||||
reduce: (&messageTextProjection{}).reduceAdded,
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.CustomTextSetEventType),
|
||||
instance.AggregateType,
|
||||
[]byte(`{
|
||||
event: getEvent(
|
||||
testEvent(
|
||||
instance.CustomTextSetEventType,
|
||||
instance.AggregateType,
|
||||
[]byte(`{
|
||||
"key": "Title",
|
||||
"language": "en",
|
||||
"template": "InitCode",
|
||||
"text": "Test"
|
||||
}`),
|
||||
), instance.CustomTextSetEventMapper),
|
||||
), instance.CustomTextSetEventMapper),
|
||||
},
|
||||
want: wantReduce{
|
||||
aggregateType: eventstore.AggregateType("instance"),
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
aggregateType: eventstore.AggregateType("instance"),
|
||||
sequence: 15,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
@@ -648,21 +647,21 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
{
|
||||
name: "instance reduceRemoved Title",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.CustomTextRemovedEventType),
|
||||
instance.AggregateType,
|
||||
[]byte(`{
|
||||
event: getEvent(
|
||||
testEvent(
|
||||
instance.CustomTextRemovedEventType,
|
||||
instance.AggregateType,
|
||||
[]byte(`{
|
||||
"key": "Title",
|
||||
"language": "en",
|
||||
"template": "InitCode"
|
||||
}`),
|
||||
), instance.CustomTextRemovedEventMapper),
|
||||
), instance.CustomTextRemovedEventMapper),
|
||||
},
|
||||
reduce: (&messageTextProjection{}).reduceRemoved,
|
||||
want: wantReduce{
|
||||
aggregateType: eventstore.AggregateType("instance"),
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
aggregateType: eventstore.AggregateType("instance"),
|
||||
sequence: 15,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
@@ -685,16 +684,16 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
name: "org.reduceOwnerRemoved",
|
||||
reduce: (&messageTextProjection{}).reduceOwnerRemoved,
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.OrgRemovedEventType),
|
||||
org.AggregateType,
|
||||
nil,
|
||||
), org.OrgRemovedEventMapper),
|
||||
event: getEvent(
|
||||
testEvent(
|
||||
org.OrgRemovedEventType,
|
||||
org.AggregateType,
|
||||
nil,
|
||||
), org.OrgRemovedEventMapper),
|
||||
},
|
||||
want: wantReduce{
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
|
Reference in New Issue
Block a user