kafka-sink-statistics.td 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. $ set-arg-default single-replica-cluster=quickstart
  10. $ postgres-execute connection=postgres://mz_system:materialize@${testdrive.materialize-internal-sql-addr}
  11. ALTER SYSTEM SET storage_statistics_collection_interval = 1000
  12. ALTER SYSTEM SET storage_statistics_interval = 2000
  13. ALTER SYSTEM SET kafka_socket_timeout = 5000
  14. ALTER SYSTEM SET kafka_transaction_timeout = 5100
  15. > CREATE CONNECTION kafka_conn
  16. TO KAFKA (BROKER '${testdrive.kafka-addr}', SECURITY PROTOCOL PLAINTEXT);
  17. > CREATE TABLE t (a text, b text)
  18. > CREATE MATERIALIZED VIEW simple_view AS SELECT * from t;
  19. > CREATE SINK simple_view_sink
  20. IN CLUSTER ${arg.single-replica-cluster}
  21. FROM simple_view
  22. INTO KAFKA CONNECTION kafka_conn (TOPIC 'topic-${testdrive.seed}')
  23. KEY (a)
  24. FORMAT JSON
  25. ENVELOPE DEBEZIUM
  26. > INSERT INTO t VALUES ('key1', 'value')
  27. # NOTE: These queries are slow to succeed because the default metrics scraping
  28. # interval is 60 seconds.
  29. $ set-sql-timeout duration=2minutes
  30. > SELECT s.name, SUM(u.messages_staged), SUM(u.messages_committed), SUM(u.bytes_staged) > 0, SUM(bytes_staged) = SUM(bytes_committed)
  31. FROM mz_sinks s
  32. JOIN mz_internal.mz_sink_statistics_raw u ON s.id = u.id
  33. WHERE s.name IN ('simple_view_sink')
  34. GROUP BY s.name
  35. ORDER BY s.name
  36. simple_view_sink 1 1 true true
  37. > INSERT INTO t VALUES ('key1', 'value')
  38. > SELECT s.name, SUM(u.messages_staged), SUM(u.messages_committed), SUM(u.bytes_staged) > 0, SUM(bytes_staged) = SUM(bytes_committed)
  39. FROM mz_sinks s
  40. JOIN mz_internal.mz_sink_statistics_raw u ON s.id = u.id
  41. WHERE s.name IN ('simple_view_sink')
  42. GROUP BY s.name
  43. ORDER BY s.name
  44. simple_view_sink 2 2 true true
  45. # check the aggregated view as well
  46. > SELECT s.name, u.messages_staged, u.messages_committed, u.bytes_staged > 0, bytes_staged = bytes_committed
  47. FROM mz_sinks s
  48. JOIN mz_internal.mz_sink_statistics u ON s.id = u.id
  49. WHERE s.name IN ('simple_view_sink')
  50. simple_view_sink 2 2 true true
  51. > ALTER CONNECTION kafka_conn SET (BROKER 'asdf') WITH (VALIDATE = false);
  52. # Ensure we shut down first, so the insert later comes after we have restarted.
  53. > SELECT count(*) > 0 FROM mz_internal.mz_sink_status_history
  54. JOIN mz_sinks ON mz_sink_status_history.sink_id = mz_sinks.id
  55. WHERE status = 'stalled'
  56. AND name = 'simple_view_sink'
  57. true
  58. > ALTER CONNECTION kafka_conn SET (BROKER '${testdrive.kafka-addr}') WITH (VALIDATE = true);
  59. > SELECT status FROM mz_internal.mz_sink_statuses
  60. WHERE name = 'simple_view_sink'
  61. running
  62. > INSERT INTO t VALUES ('key1', 'value')
  63. > SELECT s.name, u.messages_staged, u.messages_committed, u.bytes_staged > 0, bytes_staged = bytes_committed
  64. FROM mz_sinks s
  65. JOIN mz_internal.mz_sink_statistics u ON s.id = u.id
  66. WHERE s.name IN ('simple_view_sink')
  67. simple_view_sink 3 3 true true