silent-connection-drop-part-1.td 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. # IMPORTANT: The Postgres server has a custom pg_hba.conf that only
  10. # accepts connections from specific users. You will have to update
  11. # pg_hba.conf if you modify the existing user names or add new ones.
  12. $ postgres-execute connection=postgres://mz_system:materialize@${testdrive.materialize-internal-sql-addr}
  13. ALTER SYSTEM SET pg_source_wal_sender_timeout = ''
  14. ALTER SYSTEM SET pg_source_tcp_configure_server = FALSE
  15. > DROP SOURCE IF EXISTS mz_source CASCADE;
  16. > DROP SECRET IF EXISTS pgpass CASCADE;
  17. > DROP CONNECTION IF EXISTS pg_conn CASCADE;
  18. > CREATE SECRET pgpass AS 'postgres'
  19. > CREATE CONNECTION pg_conn TO POSTGRES (
  20. HOST postgres,
  21. DATABASE postgres,
  22. USER postgres,
  23. PASSWORD SECRET pgpass
  24. )
  25. > CREATE CLUSTER sconn_drop_cluster SIZE '${arg.default-replica-size}'
  26. $ postgres-execute connection=postgres://postgres:postgres@postgres
  27. ALTER USER postgres WITH replication;
  28. DROP SCHEMA IF EXISTS public CASCADE;
  29. CREATE SCHEMA public;
  30. DROP PUBLICATION IF EXISTS mz_source;
  31. CREATE PUBLICATION mz_source FOR ALL TABLES;
  32. CREATE TABLE table_1 (pk INTEGER PRIMARY KEY, f2 TEXT);
  33. INSERT INTO table_1 VALUES (1, 'one');
  34. ALTER TABLE table_1 REPLICA IDENTITY FULL;
  35. INSERT INTO table_1 VALUES (2, 'two');
  36. INSERT INTO table_1 VALUES (3, 'three');
  37. > CREATE SOURCE mz_source
  38. IN CLUSTER sconn_drop_cluster
  39. FROM POSTGRES CONNECTION pg_conn (PUBLICATION 'mz_source')
  40. FOR TABLES (table_1);
  41. > SELECT * FROM table_1;
  42. 1 one
  43. 2 two
  44. 3 three
  45. # disable cluster
  46. > ALTER CLUSTER sconn_drop_cluster SET (REPLICATION FACTOR 0)