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

@@ -12,8 +12,7 @@ import (
"github.com/zitadel/zitadel/internal/database"
"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/quota"
)
@@ -32,7 +31,7 @@ func TestQuotasProjection_reduces(t *testing.T) {
name: "reduceQuotaSet with added type",
args: args{
event: getEvent(testEvent(
repository.EventType(quota.AddedEventType),
quota.AddedEventType,
quota.AggregateType,
[]byte(`{
"unit": 1,
@@ -45,9 +44,8 @@ func TestQuotasProjection_reduces(t *testing.T) {
},
reduce: (&quotaProjection{}).reduceQuotaSet,
want: wantReduce{
aggregateType: eventstore.AggregateType("quota"),
sequence: 15,
previousSequence: 10,
aggregateType: eventstore.AggregateType("quota"),
sequence: 15,
executer: &testExecuter{
executions: []execution{
{
@@ -70,7 +68,7 @@ func TestQuotasProjection_reduces(t *testing.T) {
name: "reduceQuotaAdded with added type and notification",
args: args{
event: getEvent(testEvent(
repository.EventType(quota.AddedEventType),
quota.AddedEventType,
quota.AggregateType,
[]byte(`{
"unit": 1,
@@ -91,9 +89,8 @@ func TestQuotasProjection_reduces(t *testing.T) {
},
reduce: (&quotaProjection{}).reduceQuotaSet,
want: wantReduce{
aggregateType: eventstore.AggregateType("quota"),
sequence: 15,
previousSequence: 10,
aggregateType: eventstore.AggregateType("quota"),
sequence: 15,
executer: &testExecuter{
executions: []execution{
{
@@ -134,7 +131,7 @@ func TestQuotasProjection_reduces(t *testing.T) {
name: "reduceQuotaSet with set type",
args: args{
event: getEvent(testEvent(
repository.EventType(quota.SetEventType),
quota.SetEventType,
quota.AggregateType,
[]byte(`{
"unit": 1,
@@ -147,9 +144,8 @@ func TestQuotasProjection_reduces(t *testing.T) {
},
reduce: (&quotaProjection{}).reduceQuotaSet,
want: wantReduce{
aggregateType: eventstore.AggregateType("quota"),
sequence: 15,
previousSequence: 10,
aggregateType: eventstore.AggregateType("quota"),
sequence: 15,
executer: &testExecuter{
executions: []execution{
{
@@ -172,7 +168,7 @@ func TestQuotasProjection_reduces(t *testing.T) {
name: "reduceQuotaAdded with set type and notification",
args: args{
event: getEvent(testEvent(
repository.EventType(quota.SetEventType),
quota.SetEventType,
quota.AggregateType,
[]byte(`{
"unit": 1,
@@ -193,9 +189,8 @@ func TestQuotasProjection_reduces(t *testing.T) {
},
reduce: (&quotaProjection{}).reduceQuotaSet,
want: wantReduce{
aggregateType: eventstore.AggregateType("quota"),
sequence: 15,
previousSequence: 10,
aggregateType: eventstore.AggregateType("quota"),
sequence: 15,
executer: &testExecuter{
executions: []execution{
{
@@ -236,7 +231,7 @@ func TestQuotasProjection_reduces(t *testing.T) {
name: "reduceQuotaNotificationDue",
args: args{
event: getEvent(testEvent(
repository.EventType(quota.NotificationDueEventType),
quota.NotificationDueEventType,
quota.AggregateType,
[]byte(`{
"id": "id",
@@ -250,9 +245,8 @@ func TestQuotasProjection_reduces(t *testing.T) {
},
reduce: (&quotaProjection{}).reduceQuotaNotificationDue,
want: wantReduce{
aggregateType: eventstore.AggregateType("quota"),
sequence: 15,
previousSequence: 10,
aggregateType: eventstore.AggregateType("quota"),
sequence: 15,
executer: &testExecuter{
executions: []execution{
{
@@ -273,7 +267,7 @@ func TestQuotasProjection_reduces(t *testing.T) {
name: "reduceQuotaRemoved",
args: args{
event: getEvent(testEvent(
repository.EventType(quota.RemovedEventType),
quota.RemovedEventType,
quota.AggregateType,
[]byte(`{
"unit": 1
@@ -282,9 +276,8 @@ func TestQuotasProjection_reduces(t *testing.T) {
},
reduce: (&quotaProjection{}).reduceQuotaRemoved,
want: wantReduce{
aggregateType: eventstore.AggregateType("quota"),
sequence: 15,
previousSequence: 10,
aggregateType: eventstore.AggregateType("quota"),
sequence: 15,
executer: &testExecuter{
executions: []execution{
{
@@ -315,7 +308,7 @@ func TestQuotasProjection_reduces(t *testing.T) {
name: "reduceInstanceRemoved",
args: args{
event: getEvent(testEvent(
repository.EventType(instance.InstanceRemovedEventType),
instance.InstanceRemovedEventType,
instance.AggregateType,
[]byte(`{
"name": "name"
@@ -324,9 +317,8 @@ func TestQuotasProjection_reduces(t *testing.T) {
},
reduce: (&quotaProjection{}).reduceInstanceRemoved,
want: wantReduce{
aggregateType: eventstore.AggregateType("instance"),
sequence: 15,
previousSequence: 10,
aggregateType: eventstore.AggregateType("instance"),
sequence: 15,
executer: &testExecuter{
executions: []execution{
{