mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 01:37: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:
@@ -1,12 +1,9 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"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"
|
||||
)
|
||||
|
||||
type HumanWebAuthNAddedEvent struct {
|
||||
@@ -17,11 +14,11 @@ type HumanWebAuthNAddedEvent struct {
|
||||
RPID string `json:"rpID,omitempty"`
|
||||
}
|
||||
|
||||
func (e *HumanWebAuthNAddedEvent) Data() interface{} {
|
||||
func (e *HumanWebAuthNAddedEvent) Payload() interface{} {
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *HumanWebAuthNAddedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
|
||||
func (e *HumanWebAuthNAddedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -39,11 +36,11 @@ func NewHumanWebAuthNAddedEvent(
|
||||
}
|
||||
}
|
||||
|
||||
func HumanWebAuthNAddedEventMapper(event *repository.Event) (eventstore.Event, error) {
|
||||
func HumanWebAuthNAddedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
webAuthNAdded := &HumanWebAuthNAddedEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
}
|
||||
err := json.Unmarshal(event.Data, webAuthNAdded)
|
||||
err := event.Unmarshal(webAuthNAdded)
|
||||
if err != nil {
|
||||
return nil, errors.ThrowInternal(err, "USER-tB8sf", "unable to unmarshal human webAuthN added")
|
||||
}
|
||||
@@ -63,11 +60,11 @@ type HumanWebAuthNVerifiedEvent struct {
|
||||
UserAgentID string `json:"userAgentID,omitempty"`
|
||||
}
|
||||
|
||||
func (e *HumanWebAuthNVerifiedEvent) Data() interface{} {
|
||||
func (e *HumanWebAuthNVerifiedEvent) Payload() interface{} {
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *HumanWebAuthNVerifiedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
|
||||
func (e *HumanWebAuthNVerifiedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -95,11 +92,11 @@ func NewHumanWebAuthNVerifiedEvent(
|
||||
}
|
||||
}
|
||||
|
||||
func HumanWebAuthNVerifiedEventMapper(event *repository.Event) (eventstore.Event, error) {
|
||||
func HumanWebAuthNVerifiedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
webauthNVerified := &HumanWebAuthNVerifiedEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
}
|
||||
err := json.Unmarshal(event.Data, webauthNVerified)
|
||||
err := event.Unmarshal(webauthNVerified)
|
||||
if err != nil {
|
||||
return nil, errors.ThrowInternal(err, "USER-B0zDs", "unable to unmarshal human webAuthN verified")
|
||||
}
|
||||
@@ -113,11 +110,11 @@ type HumanWebAuthNSignCountChangedEvent struct {
|
||||
SignCount uint32 `json:"signCount"`
|
||||
}
|
||||
|
||||
func (e *HumanWebAuthNSignCountChangedEvent) Data() interface{} {
|
||||
func (e *HumanWebAuthNSignCountChangedEvent) Payload() interface{} {
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *HumanWebAuthNSignCountChangedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
|
||||
func (e *HumanWebAuthNSignCountChangedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -133,11 +130,11 @@ func NewHumanWebAuthNSignCountChangedEvent(
|
||||
}
|
||||
}
|
||||
|
||||
func HumanWebAuthNSignCountChangedEventMapper(event *repository.Event) (eventstore.Event, error) {
|
||||
func HumanWebAuthNSignCountChangedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
webauthNVerified := &HumanWebAuthNSignCountChangedEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
}
|
||||
err := json.Unmarshal(event.Data, webauthNVerified)
|
||||
err := event.Unmarshal(webauthNVerified)
|
||||
if err != nil {
|
||||
return nil, errors.ThrowInternal(err, "USER-5Gm0s", "unable to unmarshal human webAuthN sign count")
|
||||
}
|
||||
@@ -151,11 +148,11 @@ type HumanWebAuthNRemovedEvent struct {
|
||||
State domain.MFAState `json:"-"`
|
||||
}
|
||||
|
||||
func (e *HumanWebAuthNRemovedEvent) Data() interface{} {
|
||||
func (e *HumanWebAuthNRemovedEvent) Payload() interface{} {
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *HumanWebAuthNRemovedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
|
||||
func (e *HumanWebAuthNRemovedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -169,11 +166,11 @@ func NewHumanWebAuthNRemovedEvent(
|
||||
}
|
||||
}
|
||||
|
||||
func HumanWebAuthNRemovedEventMapper(event *repository.Event) (eventstore.Event, error) {
|
||||
func HumanWebAuthNRemovedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
webauthNVerified := &HumanWebAuthNRemovedEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
}
|
||||
err := json.Unmarshal(event.Data, webauthNVerified)
|
||||
err := event.Unmarshal(webauthNVerified)
|
||||
if err != nil {
|
||||
return nil, errors.ThrowInternal(err, "USER-gM9sd", "unable to unmarshal human webAuthN token removed")
|
||||
}
|
||||
@@ -189,11 +186,11 @@ type HumanWebAuthNBeginLoginEvent struct {
|
||||
*AuthRequestInfo
|
||||
}
|
||||
|
||||
func (e *HumanWebAuthNBeginLoginEvent) Data() interface{} {
|
||||
func (e *HumanWebAuthNBeginLoginEvent) Payload() interface{} {
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *HumanWebAuthNBeginLoginEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
|
||||
func (e *HumanWebAuthNBeginLoginEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -207,11 +204,11 @@ func NewHumanWebAuthNBeginLoginEvent(base *eventstore.BaseEvent, challenge strin
|
||||
}
|
||||
}
|
||||
|
||||
func HumanWebAuthNBeginLoginEventMapper(event *repository.Event) (eventstore.Event, error) {
|
||||
func HumanWebAuthNBeginLoginEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
webAuthNAdded := &HumanWebAuthNBeginLoginEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
}
|
||||
err := json.Unmarshal(event.Data, webAuthNAdded)
|
||||
err := event.Unmarshal(webAuthNAdded)
|
||||
if err != nil {
|
||||
return nil, errors.ThrowInternal(err, "USER-rMb8x", "unable to unmarshal human webAuthN begin login")
|
||||
}
|
||||
@@ -223,11 +220,11 @@ type HumanWebAuthNCheckSucceededEvent struct {
|
||||
*AuthRequestInfo
|
||||
}
|
||||
|
||||
func (e *HumanWebAuthNCheckSucceededEvent) Data() interface{} {
|
||||
func (e *HumanWebAuthNCheckSucceededEvent) Payload() interface{} {
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *HumanWebAuthNCheckSucceededEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
|
||||
func (e *HumanWebAuthNCheckSucceededEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -240,11 +237,11 @@ func NewHumanWebAuthNCheckSucceededEvent(
|
||||
}
|
||||
}
|
||||
|
||||
func HumanWebAuthNCheckSucceededEventMapper(event *repository.Event) (eventstore.Event, error) {
|
||||
func HumanWebAuthNCheckSucceededEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
webAuthNAdded := &HumanWebAuthNCheckSucceededEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
}
|
||||
err := json.Unmarshal(event.Data, webAuthNAdded)
|
||||
err := event.Unmarshal(webAuthNAdded)
|
||||
if err != nil {
|
||||
return nil, errors.ThrowInternal(err, "USER-2M0fg", "unable to unmarshal human webAuthN check succeeded")
|
||||
}
|
||||
@@ -256,11 +253,11 @@ type HumanWebAuthNCheckFailedEvent struct {
|
||||
*AuthRequestInfo
|
||||
}
|
||||
|
||||
func (e *HumanWebAuthNCheckFailedEvent) Data() interface{} {
|
||||
func (e *HumanWebAuthNCheckFailedEvent) Payload() interface{} {
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *HumanWebAuthNCheckFailedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
|
||||
func (e *HumanWebAuthNCheckFailedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -273,11 +270,11 @@ func NewHumanWebAuthNCheckFailedEvent(
|
||||
}
|
||||
}
|
||||
|
||||
func HumanWebAuthNCheckFailedEventMapper(event *repository.Event) (eventstore.Event, error) {
|
||||
func HumanWebAuthNCheckFailedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
webAuthNAdded := &HumanWebAuthNCheckFailedEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
}
|
||||
err := json.Unmarshal(event.Data, webAuthNAdded)
|
||||
err := event.Unmarshal(webAuthNAdded)
|
||||
if err != nil {
|
||||
return nil, errors.ThrowInternal(err, "USER-O0dse", "unable to unmarshal human webAuthN check failed")
|
||||
}
|
||||
|
Reference in New Issue
Block a user