max-slot-wal-keep-size.td 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. $ postgres-execute connection=postgres://postgres:postgres@postgres
  12. ALTER USER postgres WITH replication;
  13. DROP SCHEMA IF EXISTS public CASCADE;
  14. DROP PUBLICATION IF EXISTS mz_source;
  15. CREATE SCHEMA public;
  16. CREATE TABLE t1 (pk SERIAL PRIMARY KEY, f2 text);
  17. ALTER TABLE t1 REPLICA IDENTITY FULL;
  18. CREATE PUBLICATION mz_source FOR ALL TABLES;
  19. > CREATE CLUSTER storage REPLICAS (r1 (SIZE '1'))
  20. > CREATE SECRET pgpass AS 'postgres'
  21. > CREATE CONNECTION pg TO POSTGRES (
  22. HOST postgres,
  23. DATABASE postgres,
  24. USER postgres,
  25. PASSWORD SECRET pgpass
  26. )
  27. > CREATE SOURCE mz_source
  28. IN CLUSTER storage
  29. FROM POSTGRES CONNECTION pg (PUBLICATION 'mz_source')
  30. FOR ALL TABLES;
  31. # Wait for the initial snapshot to be ingested
  32. > SELECT * FROM t1
  33. # Stop ingestion by dropping the replica
  34. > DROP CLUSTER REPLICA storage.r1;
  35. # Now generate more than 10MB of WAL data so that the slot gets invalidated
  36. $set count=200000
  37. $ postgres-execute connection=postgres://postgres:postgres@postgres
  38. INSERT INTO t1 (f2) SELECT REPEAT('0123456789abcdef', 64) FROM generate_series(1, ${count}) as x;
  39. UPDATE t1 SET f2 = CONCAT(f2, pk);
  40. UPDATE t1 SET f2 = CONCAT(f2, pk);
  41. # Resume the ingestion by adding a replica to the cluster.
  42. > CREATE CLUSTER REPLICA storage.r1 SIZE = '1';
  43. ! SELECT * FROM t1;
  44. contains:replication slot has been invalidated because it exceeded the maximum reserved size