Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions .github/workflows/llm-fuzzer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,16 @@ jobs:
display_name: "Internal Program Errors"
- oracle: "optimizations"
display_name: "Optimizations ON-OFF"
- oracle: "hypertable"
display_name: "Hypertable ON-OFF"

steps:
- name: Install Linux Dependencies
timeout-minutes: 15
run: |
sudo apt-get update
sudo apt-get install ccache cmake flex bison systemd-coredump gdb \
jq postgresql-client ${{ env.extra_packages }}
sudo apt-get install ccache cmake flex bison icu-devtools systemd-coredump \
gdb jq postgresql-client ${{ env.extra_packages }}

- name: Checkout TimescaleDB
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
Expand Down Expand Up @@ -314,6 +316,14 @@ jobs:
printf '\\restrict %s\n' "${RANDOM}" > restricted-repro.sql
cat ~/llm-fuzzer-repro.sql >> restricted-repro.sql

PSQLRC=oracle-psqlrc
export PSQLRC
echo "
\set QUIET on
\set ON_ERROR_STOP on
set client_min_messages = error;
" > "${PSQLRC}"

.github/workflows/llm-fuzzer/oracle/${{ matrix.oracle }}/verify.sh restricted-repro.sql &> repro_result.txt

psql -c "select 1;"
Expand Down
143 changes: 143 additions & 0 deletions .github/workflows/llm-fuzzer/oracle/hypertable/verify.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
#!/usr/bin/env bash

# This oracle runs the reproducer script with the psql variable :hyper set
# to false and true, and compares the output. The script passes the variable
# into CREATE TABLE ... WITH (tsdb.hypertable = :hyper, ...), so the same
# statements run against a plain Postgres table and a TimescaleDB
# hypertable. The admissible bug must lead to a change in script output
# between the two.
#
# An admissible repro script:
#
# Must be runnable on same database multiple times in sequence.
#
# Must run exactly the same statements no matter if it runs against the
# plain table or the hypertable.
#
#
# Must not use the psql meta-commands.
#
# Must not require superuser privileges.
#
# The output of an admissible repro script:
#
# Must be sufficiently ordered to prevent false positives (i.e. ORDER BY, no
# ties).
#
# Must not depend on floating point precision or numeric stability.
#
# Must be independent from arbitrary environmental influence like the OID values
# or chunk identifiers.
#
# Must not change when the script runs on the same database multiple times in
# sequence.
set -eu

psql <<<'alter database :"DBNAME" set client_min_messages to error'

if ! psql -v hyper=false -f "$1" > result_plain.txt
then
echo "Repro errors out, not admissible"
exit 0
fi

if psql -v hyper=maybe -f "$1" &> result_probe.txt
then
echo "Repro does not use :hyper for tsdb.hypertable, not admissible"
exit 0
fi

if ! psql -v hyper=off -f "$1" > result_plain_synonym.txt
then
echo "Repro errors out, not admissible"
exit 0
fi


if ! psql -v hyper=true -f "$1" > result_hyper.txt
then
echo "Repro errors out, not admissible"
exit 0
fi

if ! psql -v hyper=true -c "set enable_seqscan to off;" -f "$1" > result_hyper_noseq.txt
then
echo "Repro errors out, not admissible"
exit 0
fi

if ! psql -v hyper=true -c "set enable_indexscan to off;" -f "$1" > result_hyper_noindex.txt
then
echo "Repro errors out, not admissible"
exit 0
fi

if ! psql -v hyper=true -c "set enable_hashagg to off;" -f "$1" > result_hyper_nohashagg.txt
then
echo "Repro errors out, not admissible"
exit 0
fi

if ! psql -v hyper=true -c "
set max_parallel_workers_per_gather = 8;
set parallel_setup_cost = 0;
set parallel_tuple_cost = 0;
set min_parallel_table_scan_size = 0;
set min_parallel_index_scan_size = 0;
" -f "$1" > result_hyper_para.txt
then
echo "Repro errors out, not admissible"
exit 0
fi

if ! psql -v hyper=true -c "set work_mem = '4GB'" -f "$1" > result_hyper_mem.txt
then
echo "Repro errors out, not admissible"
exit 0
fi

if ! psql -v hyper=true -c "
set enable_hashagg to off;
set enable_sort to off;
set timescaledb.enable_chunkwise_aggregation to off;
" -f "$1" > result_hyper_rowsort.txt 2> result_hyper_rowsort.err
then
echo "Repro errors out, not admissible"
exit 0
fi

if ! diff -u result_plain.txt result_plain_synonym.txt \
|| ! diff -u result_hyper.txt result_hyper_noseq.txt \
|| ! diff -u result_hyper.txt result_hyper_noindex.txt \
|| ! diff -u result_hyper.txt result_hyper_nohashagg.txt \
|| ! diff -u result_hyper.txt result_hyper_para.txt \
|| ! diff -u result_hyper.txt result_hyper_mem.txt \
|| ! diff -u result_hyper.txt result_hyper_rowsort.txt
then
echo "Repro gives different results between runs, not admissible"
exit 0
fi

echo
echo '```diff'
echo

if diff -u result_plain.txt result_hyper.txt
then
result=0
else
result=$?
fi

echo
echo '```'
echo

if [ "${result}" -eq 0 ]
then
echo "Same result with hypertable false/true, error not reproduced"
exit 0
fi

echo "Reproduced"
exit 1
23 changes: 10 additions & 13 deletions .github/workflows/llm-fuzzer/oracle/optimizations/verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,37 +29,34 @@
# sequence.
set -eu

PGOPTIONS='-c client_min_messages=error'
export PGOPTIONS
psql <<<'alter database :"DBNAME" set client_min_messages to error'
psql <<<'alter database :"DBNAME" set timescaledb.enable_optimizations to off'

psql -q <<<'alter database :"DBNAME" set client_min_messages to error'
psql -q <<<'alter database :"DBNAME" set timescaledb.enable_optimizations to off'

if ! psql -q -f "$1" > result_noopt.txt
if ! psql -f "$1" > result_noopt.txt
then
echo "Repro errors out, not admissible"
exit 0
fi

if ! psql -q -c "set enable_seqscan to off;" -f "$1" > result_noopt_noseq.txt
if ! psql -c "set enable_seqscan to off;" -f "$1" > result_noopt_noseq.txt
then
echo "Repro errors out, not admissible"
exit 0
fi

if ! psql -q -c "set enable_indexscan to off;" -f "$1" > result_noopt_noindex.txt
if ! psql -c "set enable_indexscan to off;" -f "$1" > result_noopt_noindex.txt
then
echo "Repro errors out, not admissible"
exit 0
fi

if ! psql -q -c "set enable_hashagg to off;" -f "$1" > result_noopt_nohashagg.txt
if ! psql -c "set enable_hashagg to off;" -f "$1" > result_noopt_nohashagg.txt
then
echo "Repro errors out, not admissible"
exit 0
fi

if ! psql -q -c "
if ! psql -c "
set max_parallel_workers_per_gather = 8;
set parallel_setup_cost = 0;
set parallel_tuple_cost = 0;
Expand All @@ -71,7 +68,7 @@ then
exit 0
fi

if ! psql -q -c "set work_mem = '4GB'" -f "$1" > result_noopt_mem.txt
if ! psql -c "set work_mem = '4GB'" -f "$1" > result_noopt_mem.txt
then
echo "Repro errors out, not admissible"
exit 0
Expand All @@ -87,9 +84,9 @@ then
exit 0
fi

psql -q <<<'alter database :"DBNAME" set timescaledb.enable_optimizations to on'
psql <<<'alter database :"DBNAME" set timescaledb.enable_optimizations to on'

if ! psql -q -f "$1" > result_opt.txt
if ! psql -f "$1" > result_opt.txt
then
echo "Repro errors out, not admissible"
exit 0
Expand Down
2 changes: 2 additions & 0 deletions src/partition_chunk.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,8 @@ ts_executor_end_hook(QueryDesc *queryDesc)
standard_ExecutorEnd(queryDesc);
}

/* LOOK HERE */

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this? 🤨

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing the fuzzer :) I'm marking locations with known problems and checking what it finds.


/*
* Chunks cannot be created as a partition or attached as partition until
* this point since Postgres does not allow such operations when there is
Expand Down
Loading