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

@@ -2,13 +2,11 @@ package keypair
import (
"context"
"encoding/json"
"time"
"github.com/zitadel/zitadel/internal/crypto"
"github.com/zitadel/zitadel/internal/errors"
"github.com/zitadel/zitadel/internal/eventstore"
"github.com/zitadel/zitadel/internal/eventstore/repository"
)
const (
@@ -21,11 +19,11 @@ type AddedCertificateEvent struct {
Certificate *Key `json:"certificate"`
}
func (e *AddedCertificateEvent) Data() interface{} {
func (e *AddedCertificateEvent) Payload() interface{} {
return e
}
func (e *AddedCertificateEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
func (e *AddedCertificateEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
return nil
}
@@ -47,12 +45,12 @@ func NewAddedCertificateEvent(
}
}
func AddedCertificateEventMapper(event *repository.Event) (eventstore.Event, error) {
func AddedCertificateEventMapper(event eventstore.Event) (eventstore.Event, error) {
e := &AddedCertificateEvent{
BaseEvent: *eventstore.BaseEventFromRepo(event),
}
err := json.Unmarshal(event.Data, e)
err := event.Unmarshal(e)
if err != nil {
return nil, errors.ThrowInternal(err, "KEY-4n9vs", "unable to unmarshal certificate added")
}

View File

@@ -2,14 +2,12 @@ package keypair
import (
"context"
"encoding/json"
"time"
"github.com/zitadel/zitadel/internal/crypto"
"github.com/zitadel/zitadel/internal/domain"
"github.com/zitadel/zitadel/internal/errors"
"github.com/zitadel/zitadel/internal/eventstore"
"github.com/zitadel/zitadel/internal/eventstore/repository"
)
const (
@@ -31,11 +29,11 @@ type Key struct {
Expiry time.Time `json:"expiry"`
}
func (e *AddedEvent) Data() interface{} {
func (e *AddedEvent) Payload() interface{} {
return e
}
func (e *AddedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
func (e *AddedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
return nil
}
@@ -67,12 +65,12 @@ func NewAddedEvent(
}
}
func AddedEventMapper(event *repository.Event) (eventstore.Event, error) {
func AddedEventMapper(event eventstore.Event) (eventstore.Event, error) {
e := &AddedEvent{
BaseEvent: *eventstore.BaseEventFromRepo(event),
}
err := json.Unmarshal(event.Data, e)
err := event.Unmarshal(e)
if err != nil {
return nil, errors.ThrowInternal(err, "KEY-4n8vs", "unable to unmarshal key pair added")
}