correctness-property-2.td 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. # Copyright Materialize, Inc. and contributors. All rights reserved.
  2. #
  3. # Use of this software is governed by the Business Source License
  4. # included in the LICENSE file at the root of this repository.
  5. #
  6. # As of the Change Date specified in that file, in accordance with
  7. # the Business Source License, use of this software will be governed
  8. # by the Apache License, Version 2.0.
  9. $ postgres-execute connection=postgres://mz_system:materialize@${testdrive.materialize-internal-sql-addr}
  10. ALTER SYSTEM SET unsafe_enable_unorchestrated_cluster_replicas = true
  11. $ set count=10000
  12. $ postgres-execute connection=postgres://postgres:postgres@postgres
  13. ALTER USER postgres WITH replication;
  14. DROP SCHEMA IF EXISTS public CASCADE;
  15. DROP PUBLICATION IF EXISTS mz_source;
  16. CREATE SCHEMA public;
  17. CREATE TABLE t1 (pk SERIAL PRIMARY KEY, f2 BIGINT);
  18. ALTER TABLE t1 REPLICA IDENTITY FULL;
  19. INSERT INTO t1 (f2) SELECT x FROM generate_series(1, ${count}) as x;
  20. CREATE PUBLICATION mz_source FOR ALL TABLES;
  21. # Create a cluster with no replicas so that we have time to submit queries at the minimum frontier.
  22. > CREATE CLUSTER storage REPLICAS ()
  23. > CREATE SECRET pgpass AS 'postgres'
  24. > CREATE CONNECTION pg TO POSTGRES (
  25. HOST postgres,
  26. DATABASE postgres,
  27. USER postgres,
  28. PASSWORD SECRET pgpass
  29. )
  30. > CREATE SOURCE mz_source
  31. IN CLUSTER storage
  32. FROM POSTGRES CONNECTION pg (PUBLICATION 'mz_source')
  33. FOR ALL TABLES
  34. WITH (RETAIN HISTORY = FOR '365000 days');
  35. # Grab a cursor at timestamp 0
  36. > BEGIN
  37. > DECLARE c CURSOR FOR SELECT 1, COUNT(*) FROM t1 AS OF 0
  38. # Start ingestion by adding a replica to the cluster. We must do this from a
  39. # different connection to not disturbe the transaction we're in.
  40. $ postgres-execute connection=postgres://materialize:materialize@${testdrive.materialize-sql-addr}
  41. CREATE CLUSTER REPLICA storage.r1 SIZE = '1';
  42. # Verify that at timestamp 0 there is only one record whose value is the final value
  43. > FETCH 1 c WITH (timeout = '1d');
  44. 1 ${count}
  45. > COMMIT