verify-rtr.td 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 allow_real_time_recency = true
  11. > SET TRANSACTION_ISOLATION = 'STRICT SERIALIZABLE';
  12. > SET REAL_TIME_RECENCY TO TRUE
  13. $ kafka-ingest topic=input_1 format=bytes repeat=500000
  14. A,B,0
  15. $ kafka-ingest topic=input_2 format=bytes repeat=500000
  16. A,B,0
  17. $ kafka-ingest topic=input_1 format=bytes repeat=500001
  18. A,B,0
  19. $ kafka-ingest topic=input_2 format=bytes repeat=500002
  20. A,B,0
  21. # This is a RTR query, so the first result should be correct
  22. $ set-max-tries max-tries=1
  23. > SELECT sum(count)
  24. FROM (
  25. SELECT count(*) FROM input_1_tbl
  26. UNION ALL SELECT count(*) FROM input_2_tbl
  27. UNION ALL SELECT count(*) FROM t
  28. ) AS x;
  29. 2000204
  30. # Do it again
  31. $ kafka-ingest topic=input_1 format=bytes repeat=500001
  32. A,B,0
  33. $ kafka-ingest topic=input_2 format=bytes repeat=500002
  34. A,B,0
  35. > SELECT sum(count)
  36. FROM (
  37. SELECT count(*) FROM input_1_tbl
  38. UNION ALL SELECT count(*) FROM input_2_tbl
  39. UNION ALL SELECT count(*) FROM t
  40. ) AS x;
  41. 3000207
  42. # Demo materialized views built on sources obey RTR.
  43. > SET REAL_TIME_RECENCY TO FALSE
  44. $ kafka-ingest topic=input_1 format=bytes repeat=500000
  45. A,B,0
  46. $ kafka-ingest topic=input_2 format=bytes repeat=500000
  47. A,B,0
  48. > SELECT sum < 4000207 FROM sum;
  49. true
  50. > SET REAL_TIME_RECENCY TO TRUE
  51. > SELECT sum FROM sum;
  52. 4000207
  53. # Do it again
  54. $ kafka-ingest topic=input_1 format=bytes repeat=500000
  55. A,B,0
  56. $ kafka-ingest topic=input_2 format=bytes repeat=500000
  57. A,B,0
  58. > SELECT sum FROM sum;
  59. 5000207
  60. $ set-regex match=(s\d+|\d{13}|u\d+|\(\d+-\d\d-\d\d\s\d\d:\d\d:\d\d\.\d\d\d\)|true|false) replacement=<>
  61. # RTR timestamp should be present.
  62. > EXPLAIN TIMESTAMP FOR SELECT sum FROM sum
  63. " query timestamp: <> <>\n oracle read timestamp: <> <>\n real time recency timestamp: <> <>\nlargest not in advance of upper: <> <>\n upper:[<> <>]\n since:[<> <>]\n can respond immediately: <>\n timeline: Some(EpochMilliseconds)\n session wall time: <> <>\n\nsource materialize.public.sum (<>, storage):\n read frontier:[<> <>]\n write frontier:[<> <>]\n\nbinding constraints:\nlower:\n (IsolationLevel(StrictSerializable)): [<> <>]\n"