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

@@ -5,8 +5,7 @@ import (
"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"
)
@@ -23,17 +22,17 @@ func TestInstanceProjection_reduces(t *testing.T) {
{
name: "reduceInstanceAdded",
args: args{
event: getEvent(testEvent(
repository.EventType(instance.InstanceAddedEventType),
instance.AggregateType,
[]byte(`{"name": "Name"}`),
), instance.InstanceAddedEventMapper),
event: getEvent(
testEvent(
instance.InstanceAddedEventType,
instance.AggregateType,
[]byte(`{"name": "Name"}`),
), instance.InstanceAddedEventMapper),
},
reduce: (&instanceProjection{}).reduceInstanceAdded,
want: wantReduce{
aggregateType: eventstore.AggregateType("instance"),
sequence: 15,
previousSequence: 10,
aggregateType: eventstore.AggregateType("instance"),
sequence: 15,
executer: &testExecuter{
executions: []execution{
{
@@ -53,17 +52,17 @@ func TestInstanceProjection_reduces(t *testing.T) {
{
name: "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(InstanceColumnID),
want: wantReduce{
aggregateType: eventstore.AggregateType("instance"),
sequence: 15,
previousSequence: 10,
aggregateType: eventstore.AggregateType("instance"),
sequence: 15,
executer: &testExecuter{
executions: []execution{
{
@@ -79,17 +78,17 @@ func TestInstanceProjection_reduces(t *testing.T) {
{
name: "reduceDefaultOrgSet",
args: args{
event: getEvent(testEvent(
repository.EventType(instance.DefaultOrgSetEventType),
instance.AggregateType,
[]byte(`{"orgId": "orgid"}`),
), instance.DefaultOrgSetMapper),
event: getEvent(
testEvent(
instance.DefaultOrgSetEventType,
instance.AggregateType,
[]byte(`{"orgId": "orgid"}`),
), instance.DefaultOrgSetMapper),
},
reduce: (&instanceProjection{}).reduceDefaultOrgSet,
want: wantReduce{
aggregateType: eventstore.AggregateType("instance"),
sequence: 15,
previousSequence: 10,
aggregateType: eventstore.AggregateType("instance"),
sequence: 15,
executer: &testExecuter{
executions: []execution{
{
@@ -108,17 +107,17 @@ func TestInstanceProjection_reduces(t *testing.T) {
{
name: "reduceProjectIDSet",
args: args{
event: getEvent(testEvent(
repository.EventType(instance.ProjectSetEventType),
instance.AggregateType,
[]byte(`{"iamProjectId": "project-id"}`),
), instance.ProjectSetMapper),
event: getEvent(
testEvent(
instance.ProjectSetEventType,
instance.AggregateType,
[]byte(`{"iamProjectId": "project-id"}`),
), instance.ProjectSetMapper),
},
reduce: (&instanceProjection{}).reduceIAMProjectSet,
want: wantReduce{
aggregateType: eventstore.AggregateType("instance"),
sequence: 15,
previousSequence: 10,
aggregateType: eventstore.AggregateType("instance"),
sequence: 15,
executer: &testExecuter{
executions: []execution{
{
@@ -137,17 +136,17 @@ func TestInstanceProjection_reduces(t *testing.T) {
{
name: "reduceDefaultLanguageSet",
args: args{
event: getEvent(testEvent(
repository.EventType(instance.DefaultLanguageSetEventType),
instance.AggregateType,
[]byte(`{"language": "en"}`),
), instance.DefaultLanguageSetMapper),
event: getEvent(
testEvent(
instance.DefaultLanguageSetEventType,
instance.AggregateType,
[]byte(`{"language": "en"}`),
), instance.DefaultLanguageSetMapper),
},
reduce: (&instanceProjection{}).reduceDefaultLanguageSet,
want: wantReduce{
aggregateType: eventstore.AggregateType("instance"),
sequence: 15,
previousSequence: 10,
aggregateType: eventstore.AggregateType("instance"),
sequence: 15,
executer: &testExecuter{
executions: []execution{
{