Field Preservation Tool - minirepro

While using YMatrix, you may encounter issues such as:

  • Slow queries
  • Query execution failures

When such problems occur, technical support personnel are required to diagnose the issue. To perform effective diagnostics, they need to reproduce the environment where the problem occurred. The minirepro tool is designed for this purpose. By providing the SQL statement that was executed, this tool generates a self-contained environment snapshot that enables engineers to reproduce and investigate the issue locally.

1 Using minirepro

The minirepro tool is installed with YMatrix in $GPHOME/bin/minirepro. You can view usage instructions by running:

[mxadmin@mdw ~]$ minirepro --help
Usage: minirepro <database> [options]

Options:
  --version             show program's version number and exit
  -?, --help            Show this help message and exit
  -h HOST, --host=HOST  Specify a remote host
  -p PORT, --port=PORT  Specify a port other than 5432
  -U USER, --user=USER  Connect as someone other than current user
  -q QUERY_FILE         file name that contains the query
  -f OUTPUT_FILE        minirepro output file name
  -l, --hll             Include HLL stats

WARNING: This tool collects statistics about your data, including most common
values, which requires some data elements to be included in the output file.
Please review output file to ensure it is within corporate policy to transport
the output file.

To preserve the execution context of an SQL statement using minirepro, first save the SQL statement into a file. For example, to preserve the execution context of the SQL statement SELECT * FROM data;, save it into a file named query.sql:

[mxadmin@mdw ~]$ cat query.sql
SELECT * FROM data;

Then run the command to connect to the database and specify the query file and output file:

[mxadmin@mdw ~]$ minirepro mxadmin -h 127.0.0.1 -U mxadmin -p 5432 -q query.sql -f outfile.sql
Connecting to database: host=127.0.0.1, port=5432, user=mxadmin, db=mxadmin ...
Extracting metadata from query file query.sql ...
psql mxadmin --pset footer --no-psqlrc -Atq -h 127.0.0.1 -p 5432 -U mxadmin -f /tmp/20210729132431/toolkit.sql
Invoking pg_dump to dump DDL ...
pg_dump -h 127.0.0.1 -p 5432 -U mxadmin -sxO mxadmin --relation-oids 32820 --function-oids 0 -f /tmp/20210729132431/pg_dump_out.sql
Writing schema DDLs ...
Writing relation and function DDLs ...
Writing table statistics ...
Writing column statistics ...
Attaching raw query text ...
--- MiniRepro completed! ---
WARNING: This tool collects statistics about your data, including most common values, which requires some data elements to be included in the output file.
Please review output file to ensure it is within corporate policy to transport the output file.

The execution environment is now preserved in the outfile.sql file. This file contains table definitions and related catalog information. Provide this file to technical support for further analysis.