Skip to content

Instantly share code, notes, and snippets.

@mgartner
Last active September 14, 2021 14:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mgartner/5aa462fc34f5434df5e06da3b71e74cb to your computer and use it in GitHub Desktop.
Save mgartner/5aa462fc34f5434df5e06da3b71e74cb to your computer and use it in GitHub Desktop.
Example for reducing a TLP query
-- How to reduce a TLP query.
-- Below is an example where the TLP predicate is `true`.
-- Put this at the end of a failing tlp.log.
SELECT IF(
(
SELECT count(*) FROM (
-- Count all rows in the table here.
SELECT count(*) FROM t
INTERSECT
-- Count up the three TLP partitions here.
SELECT count(*) FROM (
-- TLP partition 1
SELECT count(*) FROM t WHERE true
UNION ALL
-- TLP partition 2
SELECT count(*) FROM t WHERE NOT true
UNION ALL
-- TLP partition 3
SELECT count(*) FROM t WHERE true IS NULL
)
)
) = 1, 1, crdb_internal.force_panic('TLP FAILURE')
);
-- Then use the bin/reduce tool to reduce the tlp.log.
--
-- ./bin/reduce -contains 'crdb_internal' -binary ./cockroach -file tlp.log -v -chunk 15
--
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment