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

@@ -1,12 +1,8 @@
package policy
import (
"encoding/json"
"github.com/zitadel/zitadel/internal/eventstore"
"github.com/zitadel/zitadel/internal/errors"
"github.com/zitadel/zitadel/internal/eventstore/repository"
"github.com/zitadel/zitadel/internal/eventstore"
)
const (
@@ -25,11 +21,11 @@ type PasswordComplexityPolicyAddedEvent struct {
HasSymbol bool `json:"hasSymbol,omitempty"`
}
func (e *PasswordComplexityPolicyAddedEvent) Data() interface{} {
func (e *PasswordComplexityPolicyAddedEvent) Payload() interface{} {
return e
}
func (e *PasswordComplexityPolicyAddedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
func (e *PasswordComplexityPolicyAddedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
return nil
}
@@ -51,12 +47,12 @@ func NewPasswordComplexityPolicyAddedEvent(
}
}
func PasswordComplexityPolicyAddedEventMapper(event *repository.Event) (eventstore.Event, error) {
func PasswordComplexityPolicyAddedEventMapper(event eventstore.Event) (eventstore.Event, error) {
e := &PasswordComplexityPolicyAddedEvent{
BaseEvent: *eventstore.BaseEventFromRepo(event),
}
err := json.Unmarshal(event.Data, e)
err := event.Unmarshal(e)
if err != nil {
return nil, errors.ThrowInternal(err, "POLIC-wYxlM", "unable to unmarshal policy")
}
@@ -74,11 +70,11 @@ type PasswordComplexityPolicyChangedEvent struct {
HasSymbol *bool `json:"hasSymbol,omitempty"`
}
func (e *PasswordComplexityPolicyChangedEvent) Data() interface{} {
func (e *PasswordComplexityPolicyChangedEvent) Payload() interface{} {
return e
}
func (e *PasswordComplexityPolicyChangedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
func (e *PasswordComplexityPolicyChangedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
return nil
}
@@ -130,12 +126,12 @@ func ChangeHasSymbol(hasSymbol bool) func(*PasswordComplexityPolicyChangedEvent)
}
}
func PasswordComplexityPolicyChangedEventMapper(event *repository.Event) (eventstore.Event, error) {
func PasswordComplexityPolicyChangedEventMapper(event eventstore.Event) (eventstore.Event, error) {
e := &PasswordComplexityPolicyChangedEvent{
BaseEvent: *eventstore.BaseEventFromRepo(event),
}
err := json.Unmarshal(event.Data, e)
err := event.Unmarshal(e)
if err != nil {
return nil, errors.ThrowInternal(err, "POLIC-zBGB0", "unable to unmarshal policy")
}
@@ -147,11 +143,11 @@ type PasswordComplexityPolicyRemovedEvent struct {
eventstore.BaseEvent `json:"-"`
}
func (e *PasswordComplexityPolicyRemovedEvent) Data() interface{} {
func (e *PasswordComplexityPolicyRemovedEvent) Payload() interface{} {
return nil
}
func (e *PasswordComplexityPolicyRemovedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
func (e *PasswordComplexityPolicyRemovedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
return nil
}
@@ -161,7 +157,7 @@ func NewPasswordComplexityPolicyRemovedEvent(base *eventstore.BaseEvent) *Passwo
}
}
func PasswordComplexityPolicyRemovedEventMapper(event *repository.Event) (eventstore.Event, error) {
func PasswordComplexityPolicyRemovedEventMapper(event eventstore.Event) (eventstore.Event, error) {
return &PasswordComplexityPolicyRemovedEvent{
BaseEvent: *eventstore.BaseEventFromRepo(event),
}, nil