Skip to content

Commit

Permalink
cluster test: Add workflow_replica_expiration_creates_retraction_diff…
Browse files Browse the repository at this point in the history
…s_after_panic
  • Loading branch information
def- committed Oct 10, 2024
1 parent 65feae5 commit 5b847d4
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 35 deletions.
72 changes: 68 additions & 4 deletions test/cluster/mzcompose.py
Original file line number Diff line number Diff line change
Expand Up @@ -4840,12 +4840,10 @@ def workflow_crash_on_replica_expiration_mv(
"""
c.down(destroy_volumes=True)
with c.override(
Testdrive(no_reset=True),
Clusterd(name="clusterd1", restart="on-failure"),
):
offset = 20

c.up("testdrive", persistent=True)
c.up("materialized")
c.up("clusterd1")
c.sql(
Expand Down Expand Up @@ -4906,12 +4904,10 @@ def fetch_metrics() -> Metrics:
"""
c.down(destroy_volumes=True)
with c.override(
Testdrive(no_reset=True),
Clusterd(name="clusterd1", restart="on-failure"),
):
offset = 20

c.up("testdrive", persistent=True)
c.up("materialized")
c.up("clusterd1")
c.sql(
Expand Down Expand Up @@ -4982,3 +4978,71 @@ def fetch_metrics() -> Metrics:
assert (
1.0 < expiration_remaining < float(offset)
), f"expiration_remaining: expected < 10s, got={expiration_remaining}"


def workflow_replica_expiration_creates_retraction_diffs_after_panic(
c: Composition, parser: WorkflowArgumentParser
) -> None:
"""
Test that retraction diffs within the expiration time are generated after the replica expires and panics
"""
c.down(destroy_volumes=True)
with c.override(
Testdrive(no_reset=True),
Clusterd(name="clusterd1", restart="on-failure"),
):

c.up("testdrive", persistent=True)
c.up("materialized")
c.up("clusterd1")
c.testdrive(
dedent(
"""
$ postgres-execute connection=postgres://mz_system:materialize@${testdrive.materialize-internal-sql-addr}
ALTER SYSTEM SET enable_unorchestrated_cluster_replicas = 'true';
ALTER SYSTEM SET compute_replica_expiration_offset = '50s';
> DROP CLUSTER IF EXISTS test CASCADE;
> DROP TABLE IF EXISTS events CASCADE;
> CREATE CLUSTER test REPLICAS (
test (
STORAGECTL ADDRESSES ['clusterd1:2100'],
STORAGE ADDRESSES ['clusterd1:2103'],
COMPUTECTL ADDRESSES ['clusterd1:2101'],
COMPUTE ADDRESSES ['clusterd1:2102'],
WORKERS 1
)
);
> SET CLUSTER TO test;
> CREATE TABLE events (
content TEXT,
event_ts TIMESTAMP
);
> CREATE VIEW events_view AS
SELECT event_ts, content
FROM events
WHERE mz_now() <= event_ts + INTERVAL '80s';
> CREATE DEFAULT INDEX ON events_view;
> INSERT INTO events SELECT x::text, now() FROM generate_series(1, 1000) AS x;
# Retraction diffs are not generated
> SELECT records FROM mz_introspection.mz_dataflow_arrangement_sizes
WHERE name LIKE '%events_view_primary_idx';
1000
# Sleep until the replica expires
> SELECT mz_unsafe.mz_sleep(60);
<null>
# Retraction diffs are now within the expiration time and should be generated
> SELECT records FROM mz_introspection.mz_dataflow_arrangement_sizes
WHERE name LIKE '%events_view_primary_idx';
2000
> DROP TABLE events CASCADE;
> DROP CLUSTER test CASCADE;
"""
)
)
31 changes: 0 additions & 31 deletions test/testdrive/replica-expiration.td
Original file line number Diff line number Diff line change
Expand Up @@ -239,34 +239,3 @@ ALTER SYSTEM SET compute_replica_expiration_offset = '30d';
1000
> DROP MATERIALIZED VIEW events_mv CASCADE;
> DROP CLUSTER test CASCADE;


# Test that retraction diffs within the expiration time are generated after the replica expires and panics

$ postgres-execute connection=postgres://mz_system:materialize@${testdrive.materialize-internal-sql-addr}
ALTER SYSTEM SET compute_replica_expiration_offset = '50s';
> CREATE CLUSTER test (SIZE = '1')
> SET CLUSTER TO test
> CREATE TABLE events (
content TEXT,
event_ts TIMESTAMP
);
> CREATE VIEW events_view AS
SELECT event_ts, content
FROM events
WHERE mz_now() <= event_ts + INTERVAL '80s';
> CREATE DEFAULT INDEX ON events_view;
> INSERT INTO events SELECT x::text, now() FROM generate_series(1, 1000) AS x;
# Retraction diffs are not generated
> SELECT records FROM mz_introspection.mz_dataflow_arrangement_sizes
WHERE name LIKE '%events_view_primary_idx';
1000
# Sleep until the replica expires
> SELECT mz_unsafe.mz_sleep(60);
<null>
# Retraction diffs are now within the expiration time and should be generated
> SELECT records FROM mz_introspection.mz_dataflow_arrangement_sizes
WHERE name LIKE '%events_view_primary_idx';
2000
> DROP TABLE events CASCADE;
> DROP CLUSTER test CASCADE;

0 comments on commit 5b847d4

Please sign in to comment.