@@ -63,6 +63,7 @@ def workflow_default(c: Composition, parser: WorkflowArgumentParser) -> None:
63
63
"test-github-17177" ,
64
64
"test-github-17510" ,
65
65
"test-github-17509" ,
66
+ "test-github-19610" ,
66
67
"test-remote-storage" ,
67
68
"test-drop-default-cluster" ,
68
69
"test-upsert" ,
@@ -973,6 +974,118 @@ def workflow_test_github_17509(c: Composition) -> None:
973
974
assert "Negative accumulation in ReduceMinsMaxes" not in c1 .stdout
974
975
975
976
977
+ def workflow_test_github_19610 (c : Composition ) -> None :
978
+ """
979
+ Test that a monotonic one-shot SELECT will perform consolidation without error on valid data.
980
+ We introduce data that results in a multiset and compute min/max. In a monotonic one-shot
981
+ evaluation strategy, we must consolidate and subsequently assert monotonicity.
982
+
983
+ This is a regression test for https://github.com/MaterializeInc/materialize/issues/19610, where
984
+ we observed a performance regression caused by a correctness issue. Here, we validate that the
985
+ underlying correctness issue has been fixed.
986
+ """
987
+
988
+ c .down (destroy_volumes = True )
989
+ with c .override (
990
+ Clusterd (
991
+ name = "clusterd_nopanic" ,
992
+ environment_extra = [
993
+ "MZ_PERSIST_COMPACTION_DISABLED=true" ,
994
+ ],
995
+ ),
996
+ Testdrive (no_reset = True ),
997
+ ):
998
+ c .up ("testdrive" , persistent = True )
999
+ c .up ("materialized" )
1000
+ c .up ("clusterd_nopanic" )
1001
+
1002
+ c .sql (
1003
+ "ALTER SYSTEM SET enable_unmanaged_cluster_replicas = true;" ,
1004
+ port = 6877 ,
1005
+ user = "mz_system" ,
1006
+ )
1007
+
1008
+ c .sql (
1009
+ "ALTER SYSTEM SET enable_repeat_row = true;" ,
1010
+ port = 6877 ,
1011
+ user = "mz_system" ,
1012
+ )
1013
+
1014
+ c .sql (
1015
+ "ALTER SYSTEM SET enable_monotonic_oneshot_selects = true;" ,
1016
+ port = 6877 ,
1017
+ user = "mz_system" ,
1018
+ )
1019
+
1020
+ # set up a test cluster and run a testdrive regression script
1021
+ c .sql (
1022
+ """
1023
+ CREATE CLUSTER cluster1 REPLICAS (
1024
+ r1 (
1025
+ STORAGECTL ADDRESSES ['clusterd_nopanic:2100'],
1026
+ STORAGE ADDRESSES ['clusterd_nopanic:2103'],
1027
+ COMPUTECTL ADDRESSES ['clusterd_nopanic:2101'],
1028
+ COMPUTE ADDRESSES ['clusterd_nopanic:2102'],
1029
+ WORKERS 4
1030
+ )
1031
+ );
1032
+ -- Set data for test up.
1033
+ SET cluster = cluster1;
1034
+ CREATE TABLE base (data bigint, diff bigint);
1035
+ CREATE MATERIALIZED VIEW data AS SELECT data FROM base, repeat_row(diff);
1036
+ INSERT INTO base VALUES (1, 6);
1037
+ INSERT INTO base VALUES (1, -3), (1, -2);
1038
+ INSERT INTO base VALUES (2, 3), (2, 2);
1039
+ INSERT INTO base VALUES (2, -1), (2, -1);
1040
+ INSERT INTO base VALUES (3, 3), (3, 2);
1041
+ INSERT INTO base VALUES (3, -3), (3, -2);
1042
+ INSERT INTO base VALUES (4, 1), (4, 2);
1043
+ INSERT INTO base VALUES (4, -1), (4, -2);
1044
+ INSERT INTO base VALUES (5, 5), (5, 6);
1045
+ INSERT INTO base VALUES (5, -5), (5, -6);
1046
+ """
1047
+ )
1048
+ c .testdrive (
1049
+ dedent (
1050
+ """
1051
+ > SET cluster = cluster1;
1052
+
1053
+ # Computing min/max with a monotonic one-shot SELECT requires
1054
+ # consolidation. We test here that consolidation works correctly,
1055
+ # since we assert monotonicity right after consolidating.
1056
+ # Note that we employ a cursor to avoid testdrive retries.
1057
+ # Hash functions used for exchanges in consolidation may be
1058
+ # nondeterministic and produce the correct output by chance.
1059
+ > BEGIN
1060
+ > DECLARE cur CURSOR FOR SELECT min(data), max(data) FROM data;
1061
+ > FETCH ALL cur;
1062
+ 1 2
1063
+ > COMMIT;
1064
+
1065
+ # To reduce the chance of a (un)lucky strike of the hash function,
1066
+ # let's do the same a few times.
1067
+ > BEGIN
1068
+ > DECLARE cur CURSOR FOR SELECT min(data), max(data) FROM data;
1069
+ > FETCH ALL cur;
1070
+ 1 2
1071
+ > COMMIT;
1072
+
1073
+ > BEGIN
1074
+ > DECLARE cur CURSOR FOR SELECT min(data), max(data) FROM data;
1075
+ > FETCH ALL cur;
1076
+ 1 2
1077
+ > COMMIT;
1078
+
1079
+ > BEGIN
1080
+ > DECLARE cur CURSOR FOR SELECT min(data), max(data) FROM data;
1081
+ > FETCH ALL cur;
1082
+ 1 2
1083
+ > COMMIT;
1084
+ """
1085
+ )
1086
+ )
1087
+
1088
+
976
1089
def workflow_test_upsert (c : Composition ) -> None :
977
1090
"""Test creating upsert sources and continuing to ingest them after a restart."""
978
1091
with c .override (
0 commit comments