Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
chore: Gather backtrace from core dump on CI (#736)
Add script that check health state of postgresql after run tests, because some tests can lead to fail database with segmentation fault as it was in #734. For easy debug this scenarios and provide helpfull information to upstream we need check db state. Right now health script extract backtrace from core dumps and print logs. In the future list health checks can be increased. Example build output https://travis-ci.org/Gordiychuk/pgjdbc/builds/194050719 Sample output: The command "./.travis/travis_build.sh" exited with 1. 0.48s$ ./.travis/travis_check_postgres_health.sh Detected core dump: /etc/postgresql/HEAD/main/core Reading symbols from /usr/local/pgsql/bin/postgres...done. [New LWP 16124] [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Core was generated by `postgres: test test 127.0.0.1(54316) BIND '. Program terminated with signal SIGSEGV, Segmentation fault. #0 0x00000000007e670d in exec_bind_message (input_message=0x7ffc29a05ee0) at postgres.c:1562 1562 (!IsTransactionExitStmt(psrc->raw_parse_tree->stmt) || (gdb) #0 0x00000000007e670d in exec_bind_message (input_message=0x7ffc29a05ee0) at postgres.c:1562 portal_name = 0x1e47340 "" stmt_name = 0x1e47341 "S_3" Closes #735
- Loading branch information
Showing
with
54 additions
and 8 deletions.
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env bash | ||
|
||
check_core_dump() { | ||
local status=0 | ||
while IFS= read -r core_dump_file | ||
do | ||
status=1 | ||
echo "Detected core dump: ${core_dump_file}" | ||
echo bt full | sudo gdb --quiet /usr/local/pgsql/bin/postgres "${core_dump_file}" | ||
done < <(sudo find "${PG_DATADIR}" -type f -iname "core*") | ||
return ${status} | ||
} | ||
|
||
print_logs() { | ||
if [[ "${PG_VERSION}" = "HEAD" ]] | ||
then | ||
sudo cat /tmp/postgres.log | ||
else | ||
cat "/var/log/postgresql/postgresql-${PG_VERSION}-main.log" | ||
fi | ||
} | ||
|
||
check_core_dump | ||
if [[ $? -ne 0 ]] | ||
then | ||
print_logs | ||
exit 1 | ||
fi |
@@ -1,4 +1,4 @@ | ||
#!/usr/bin/env bash | ||
set -x -e | ||
|
||
sudo sed -i -e 's/#max_prepared_transactions = 0/max_prepared_transactions = 64/g' /etc/postgresql/${PG_VERSION}/main/postgresql.conf | ||
sudo sed -i -e 's/#max_prepared_transactions = 0/max_prepared_transactions = 64/g' ${PG_DATADIR}/postgresql.conf |