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

@@ -11,7 +11,7 @@ import (
type SearchResponse struct {
Count uint64
*LatestSequence
*State
}
type SearchRequest struct {
@@ -43,6 +43,7 @@ func (req *SearchRequest) toQuery(query sq.SelectBuilder) sq.SelectBuilder {
type SearchQuery interface {
toQuery(sq.SelectBuilder) sq.SelectBuilder
comp() sq.Sqlizer
Col() Column
}
type NotNullQuery struct {
@@ -66,6 +67,10 @@ func (q *NotNullQuery) comp() sq.Sqlizer {
return sq.NotEq{q.Column.identifier(): nil}
}
func (q *NotNullQuery) Col() Column {
return q.Column
}
type IsNullQuery struct {
Column Column
}
@@ -87,6 +92,10 @@ func (q *IsNullQuery) comp() sq.Sqlizer {
return sq.Eq{q.Column.identifier(): nil}
}
func (q *IsNullQuery) Col() Column {
return q.Column
}
type orQuery struct {
queries []SearchQuery
}
@@ -110,6 +119,10 @@ func (q *orQuery) comp() sq.Sqlizer {
return or
}
func (q *orQuery) Col() Column {
return Column{}
}
type ColumnComparisonQuery struct {
Column1 Column
Compare ColumnComparison
@@ -137,6 +150,10 @@ func (q *ColumnComparisonQuery) toQuery(query sq.SelectBuilder) sq.SelectBuilder
return query.Where(q.comp())
}
func (q *ColumnComparisonQuery) Col() Column {
return Column{}
}
func (s *ColumnComparisonQuery) comp() sq.Sqlizer {
switch s.Compare {
case ColumnEquals:
@@ -160,19 +177,10 @@ type InTextQuery struct {
Column Column
Values []string
}
type TextQuery struct {
Column Column
Text string
Compare TextComparison
}
var (
ErrNothingSelected = errors.New("nothing selected")
ErrInvalidCompare = errors.New("invalid compare")
ErrMissingColumn = errors.New("missing column")
ErrInvalidNumber = errors.New("value is no number")
ErrEmptyValues = errors.New("values array must not be empty")
)
func (q *InTextQuery) Col() Column {
return q.Column
}
func NewInTextQuery(col Column, values []string) (*InTextQuery, error) {
if len(values) == 0 {
@@ -187,6 +195,20 @@ func NewInTextQuery(col Column, values []string) (*InTextQuery, error) {
}, nil
}
type TextQuery struct {
Column Column
Text string
Compare TextComparison
}
var (
ErrNothingSelected = errors.New("nothing selected")
ErrInvalidCompare = errors.New("invalid compare")
ErrMissingColumn = errors.New("missing column")
ErrInvalidNumber = errors.New("value is no number")
ErrEmptyValues = errors.New("values array must not be empty")
)
func NewTextQuery(col Column, value string, compare TextComparison) (*TextQuery, error) {
if compare < 0 || compare >= textCompareMax {
return nil, ErrInvalidCompare
@@ -201,6 +223,10 @@ func NewTextQuery(col Column, value string, compare TextComparison) (*TextQuery,
}, nil
}
func (q *TextQuery) Col() Column {
return q.Column
}
func (q *InTextQuery) toQuery(query sq.SelectBuilder) sq.SelectBuilder {
return query.Where(q.comp())
}
@@ -311,6 +337,10 @@ func (q *NumberQuery) toQuery(query sq.SelectBuilder) sq.SelectBuilder {
return query.Where(q.comp())
}
func (q *NumberQuery) Col() Column {
return q.Column
}
func (s *NumberQuery) comp() sq.Sqlizer {
switch s.Compare {
case NumberEquals:
@@ -427,6 +457,10 @@ func (s *ListQuery) comp() sq.Sqlizer {
return nil
}
func (q *ListQuery) Col() Column {
return q.Column
}
type ListComparison int
const (
@@ -466,6 +500,10 @@ func (q *or) comp() sq.Sqlizer {
return sq.Or(queries)
}
func (q *or) Col() Column {
return Column{}
}
type BoolQuery struct {
Column Column
Value bool
@@ -478,6 +516,10 @@ func NewBoolQuery(c Column, value bool) (*BoolQuery, error) {
}, nil
}
func (q *BoolQuery) Col() Column {
return q.Column
}
func (q *BoolQuery) toQuery(query sq.SelectBuilder) sq.SelectBuilder {
return query.Where(q.comp())
}