mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 21:07:31 +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,23 +24,23 @@ func TestPasswordComplexityProjection_reduces(t *testing.T) {
|
||||
{
|
||||
name: "org reduceAdded",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.PasswordComplexityPolicyAddedEventType),
|
||||
org.AggregateType,
|
||||
[]byte(`{
|
||||
event: getEvent(
|
||||
testEvent(
|
||||
org.PasswordComplexityPolicyAddedEventType,
|
||||
org.AggregateType,
|
||||
[]byte(`{
|
||||
"minLength": 10,
|
||||
"hasLowercase": true,
|
||||
"hasUppercase": true,
|
||||
"HasNumber": true,
|
||||
"HasSymbol": true
|
||||
}`),
|
||||
), org.PasswordComplexityPolicyAddedEventMapper),
|
||||
), org.PasswordComplexityPolicyAddedEventMapper),
|
||||
},
|
||||
reduce: (&passwordComplexityProjection{}).reduceAdded,
|
||||
want: wantReduce{
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
@@ -70,22 +69,22 @@ func TestPasswordComplexityProjection_reduces(t *testing.T) {
|
||||
name: "org reduceChanged",
|
||||
reduce: (&passwordComplexityProjection{}).reduceChanged,
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.PasswordComplexityPolicyChangedEventType),
|
||||
org.AggregateType,
|
||||
[]byte(`{
|
||||
event: getEvent(
|
||||
testEvent(
|
||||
org.PasswordComplexityPolicyChangedEventType,
|
||||
org.AggregateType,
|
||||
[]byte(`{
|
||||
"minLength": 11,
|
||||
"hasLowercase": true,
|
||||
"hasUppercase": true,
|
||||
"HasNumber": true,
|
||||
"HasSymbol": true
|
||||
}`),
|
||||
), org.PasswordComplexityPolicyChangedEventMapper),
|
||||
), org.PasswordComplexityPolicyChangedEventMapper),
|
||||
},
|
||||
want: wantReduce{
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
@@ -110,16 +109,16 @@ func TestPasswordComplexityProjection_reduces(t *testing.T) {
|
||||
name: "org reduceRemoved",
|
||||
reduce: (&passwordComplexityProjection{}).reduceRemoved,
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.PasswordComplexityPolicyRemovedEventType),
|
||||
org.AggregateType,
|
||||
nil,
|
||||
), org.PasswordComplexityPolicyRemovedEventMapper),
|
||||
event: getEvent(
|
||||
testEvent(
|
||||
org.PasswordComplexityPolicyRemovedEventType,
|
||||
org.AggregateType,
|
||||
nil,
|
||||
), org.PasswordComplexityPolicyRemovedEventMapper),
|
||||
},
|
||||
want: wantReduce{
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
@@ -136,17 +135,17 @@ func TestPasswordComplexityProjection_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(ComplexityPolicyInstanceIDCol),
|
||||
want: wantReduce{
|
||||
aggregateType: eventstore.AggregateType("instance"),
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
aggregateType: eventstore.AggregateType("instance"),
|
||||
sequence: 15,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
@@ -163,22 +162,22 @@ func TestPasswordComplexityProjection_reduces(t *testing.T) {
|
||||
name: "instance reduceAdded",
|
||||
reduce: (&passwordComplexityProjection{}).reduceAdded,
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.PasswordComplexityPolicyAddedEventType),
|
||||
instance.AggregateType,
|
||||
[]byte(`{
|
||||
event: getEvent(
|
||||
testEvent(
|
||||
instance.PasswordComplexityPolicyAddedEventType,
|
||||
instance.AggregateType,
|
||||
[]byte(`{
|
||||
"minLength": 10,
|
||||
"hasLowercase": true,
|
||||
"hasUppercase": true,
|
||||
"HasNumber": true,
|
||||
"HasSymbol": true
|
||||
}`),
|
||||
), instance.PasswordComplexityPolicyAddedEventMapper),
|
||||
), instance.PasswordComplexityPolicyAddedEventMapper),
|
||||
},
|
||||
want: wantReduce{
|
||||
aggregateType: eventstore.AggregateType("instance"),
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
aggregateType: eventstore.AggregateType("instance"),
|
||||
sequence: 15,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
@@ -207,22 +206,22 @@ func TestPasswordComplexityProjection_reduces(t *testing.T) {
|
||||
name: "instance reduceChanged",
|
||||
reduce: (&passwordComplexityProjection{}).reduceChanged,
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.PasswordComplexityPolicyChangedEventType),
|
||||
instance.AggregateType,
|
||||
[]byte(`{
|
||||
event: getEvent(
|
||||
testEvent(
|
||||
instance.PasswordComplexityPolicyChangedEventType,
|
||||
instance.AggregateType,
|
||||
[]byte(`{
|
||||
"minLength": 10,
|
||||
"hasLowercase": true,
|
||||
"hasUppercase": true,
|
||||
"HasNumber": true,
|
||||
"HasSymbol": true
|
||||
}`),
|
||||
), instance.PasswordComplexityPolicyChangedEventMapper),
|
||||
), instance.PasswordComplexityPolicyChangedEventMapper),
|
||||
},
|
||||
want: wantReduce{
|
||||
aggregateType: eventstore.AggregateType("instance"),
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
aggregateType: eventstore.AggregateType("instance"),
|
||||
sequence: 15,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
@@ -247,16 +246,16 @@ func TestPasswordComplexityProjection_reduces(t *testing.T) {
|
||||
name: "org.reduceOwnerRemoved",
|
||||
reduce: (&passwordComplexityProjection{}).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