Skip to content

Commit

Permalink
add parallel tests to sanitizer container. Fix assertion violation in…
Browse files Browse the repository at this point in the history
… operator rewriting
  • Loading branch information
ezra-varady committed Oct 26, 2023
1 parent fcddebd commit 1d0c513
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
9 changes: 8 additions & 1 deletion scripts/sanitizers/run_sanitizers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,14 @@ docker exec -i -u root lantern-sanitizers /bin/bash <<EOF
chown -R postgres:postgres /lantern/sanitizer
EOF

DIFF_PATH=/tmp/lantern/tmp_output/regression.diffs
docker exec -i -u postgres -w /lantern/build lantern-sanitizers /bin/bash <<EOF
make test
cp /tmp/lantern/tmp_output/results/*.out /lantern/sanitizer
if test -f $DIFF_PATH; then
cp /tmp/lantern/tmp_output/regression.diffs /lantern/sanitizer/test.diffs
fi
make test-parallel
if test -f $DIFF_PATH; then
cp /tmp/lantern/tmp_output/regression.diffs /lantern/sanitizer/test-parallel.diffs
fi
EOF
11 changes: 9 additions & 2 deletions src/hooks/op_rewrite.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <parser/parsetree.h>
#include <stdbool.h>
#include <stdint.h>
#include <utils/catcache.h>
#include <utils/memutils.h>
#include <utils/rel.h>
#include <utils/syscache.h>
Expand Down Expand Up @@ -166,13 +167,19 @@ static Oid get_func_id_from_index(Relation index)
ReleaseSysCache(opclassTuple);

// SELECT * FROM pg_amproc WHERE amprocfamily=opclassOid
HeapTuple opTuple = SearchSysCache1(AMPROCNUM, ObjectIdGetDatum(opclassOid));
// SearchSysCache1 is what we want and in fact it runs fine against release builds. However debug builds assert that
// AMPROCNUM takes only 1 arg which isn't true and so they fail. We therefore have to use SearchSysCacheList1 since
// it doesn't enforce this invariant. Ideally we would call SearchCatCache1 directly but postgres doesn't expose
// necessary constants
CatCList *opList = SearchSysCacheList1(AMPROCNUM, ObjectIdGetDatum(opclassOid));
assert(opList->n_members == 1);
HeapTuple opTuple = &opList->members[ 0 ]->tuple;
if(!HeapTupleIsValid(opTuple)) {
index_close(index, AccessShareLock);
elog(ERROR, "Failed to find the function for operator class");
}
Oid functionId = ((Form_pg_amproc)GETSTRUCT(opTuple))->amproc;
ReleaseSysCache(opTuple);
ReleaseCatCacheList(opList);

return functionId;
}
Expand Down

0 comments on commit 1d0c513

Please sign in to comment.