frontier-rounding.td 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. # Tests checking that frontiers of storage collections, at least when they
  10. # don't receive data updates, are rounded to seconds. This is important because
  11. # it ensures that all dataflow sources tick forward at the same time, reducing
  12. # the number of distinct times dataflows have to process, thus removing some
  13. # overhead.
  14. #
  15. # Note that we expect frontiers to be of the form XX..XX001, i.e. rounded to
  16. # seconds and then stepped forward. That's because things that tick forward
  17. # collections choose XX..XX000 as the append timestamp, and then the new write
  18. # frontier must be greater than that.
  19. #
  20. # The rounding is currently not working correctly for tables, compute
  21. # introspection sources, storage-managed collections. See database-issues#9030.
  22. $ kafka-create-topic topic=topic partitions=1
  23. > CREATE CONNECTION kafka_conn
  24. TO KAFKA (BROKER '${testdrive.kafka-addr}', SECURITY PROTOCOL PLAINTEXT)
  25. > CREATE SOURCE src
  26. FROM KAFKA CONNECTION kafka_conn (TOPIC 'testdrive-topic-${testdrive.seed}')
  27. > CREATE SOURCE ctr FROM LOAD GENERATOR COUNTER
  28. > CREATE SOURCE actn FROM LOAD GENERATOR AUCTION FOR ALL TABLES
  29. # sources
  30. > SELECT DISTINCT write_frontier::text::uint8 % 1000 = 1
  31. FROM mz_internal.mz_frontiers
  32. JOIN mz_sources ON id = object_id
  33. WHERE object_id LIKE 'u%'
  34. true
  35. # tables
  36. # fails: frontiers are not rounded
  37. # > SELECT DISTINCT write_frontier::text::uint8 % 1000 = 1
  38. # FROM mz_internal.mz_frontiers
  39. # JOIN mz_tables ON id = object_id
  40. # true
  41. # compute introspection sources
  42. # fails: frontiers are rounded to `XX..XX000` instead of `XX..XX001`
  43. # > SELECT DISTINCT write_frontier::text::uint8 % 1000 = 1
  44. # FROM mz_internal.mz_frontiers
  45. # WHERE object_id LIKE 'si%'
  46. # true
  47. # storage-managed collections
  48. # fails: frontiers are not rounded
  49. # > SELECT DISTINCT write_frontier::text::uint8 % 1000 = 1
  50. # FROM mz_internal.mz_frontiers
  51. # JOIN mz_sources ON id = object_id
  52. # WHERE object_id LIKE 's%'
  53. # true