fix: smaller outage on events migration first part (#2287)

This commit is contained in:
Silvan 2021-09-01 09:59:24 +02:00 committed by GitHub
parent 31a91a0039
commit f9203940fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 13 additions and 45 deletions

View File

@ -44,10 +44,11 @@ func StartQueries(ctx context.Context, es *eventstore.Eventstore, projections pr
return nil, err
}
err = projection.Start(ctx, es, projections)
if err != nil {
return nil, err
}
// turned off for this release
// err = projection.Start(ctx, es, projections)
// if err != nil {
// return nil, err
// }
return repo, nil
}

View File

@ -1,40 +0,0 @@
BEGIN;
ALTER TABLE eventstore.events
RENAME COLUMN previous_sequence TO previous_aggregate_sequence,
ADD COLUMN previous_aggregate_type_sequence INT8,
ADD CONSTRAINT prev_agg_type_seq_unique UNIQUE(previous_aggregate_type_sequence);
COMMIT;
SET CLUSTER SETTING kv.closed_timestamp.target_duration = '2m';
BEGIN;
WITH data AS (
SELECT
event_sequence,
LAG(event_sequence)
OVER (
PARTITION BY aggregate_type
ORDER BY event_sequence
) as prev_seq,
aggregate_type
FROM eventstore.events
ORDER BY event_sequence
) UPDATE eventstore.events
SET previous_aggregate_type_sequence = data.prev_seq
FROM data
WHERE data.event_sequence = events.event_sequence;
COMMIT;
SET CLUSTER SETTING kv.closed_timestamp.target_duration TO DEFAULT;
-- validation by hand:
-- SELECT
-- event_sequence,
-- previous_aggregate_sequence,
-- previous_aggregate_type_sequence,
-- aggregate_type,
-- aggregate_id,
-- event_type
-- FROM eventstore.events ORDER BY event_sequence;

View File

@ -1 +0,0 @@
CREATE INDEX agg_type ON eventstore.events (aggregate_type);

View File

@ -0,0 +1,8 @@
BEGIN;
ALTER TABLE eventstore.events
RENAME COLUMN previous_sequence TO previous_aggregate_sequence,
ADD COLUMN previous_aggregate_type_sequence INT8,
ADD CONSTRAINT prev_agg_type_seq_unique UNIQUE(previous_aggregate_type_sequence);
COMMIT;