Произошла непредвиденная ошибка при использовании команды s sh psql - PullRequest
1 голос
/ 17 апреля 2020

когда я запускаю файл bash в docker, я планирую запустить некоторую команду psql через один сервер A на другом сервере (сервере базы данных), который имеет базу данных postgresql, но там указано

[ERROR] [   trapError] An unexpected error occured at line 141 ./functions.sh`

Подробности этого bash файла:

executeSql() {
  local tmp="/tmp/executeSql"
  ssh ${DBUSERHOST} "sudo -u postgres psql -c \"${SQL}\" -d studenta" > ${tmp} 2>&1
  ST=$?
  if [ "${ST}" != "0" ]; then
    ERROR "Failed to execute sql query"
    cat "${tmp}" >> "${LOGFILE}"
    exit 10
  fi
}

Строка 141 соответствует

ssh ${DBUSERHOST} "sudo -u postgres psql -c \"${SQL}\" -d studenta" > ${tmp} 2>&1

Когда я проверяю журнал в контейнере PostgreSQL, он показывает это:

...
REVOKE
REVOKE
GRANT
GRANT

LOG:  received fast shutdown request
LOG:  aborting any active transactions
FATAL:  terminating autovacuum process due to administrator command
FATAL:  terminating autovacuum process due to administrator command
LOG:  autovacuum launcher shutting down
FATAL:  terminating autovacuum process due to administrator command
waiting for server to shut down....LOG:  shutting down
LOG:  database system is shut down
 done
server stopped

PostgreSQL init process complete; ready for start up.

LOG:  database system was shut down at 2020-04-16 19:23:04 UTC
LOG:  MultiXact member wraparound protections are now enabled
LOG:  database system is ready to accept connections
LOG:  autovacuum launcher started
LOG:  server process (PID 165) exited with exit code 255
LOG:  terminating any other active server processes
WARNING:  terminating connection because of crash of another server process
DETAIL:  The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.
HINT:  In a moment you should be able to reconnect to the database and repeat your command.
WARNING:  terminating connection because of crash of another server process
DETAIL:  The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.
HINT:  In a moment you should be able to reconnect to the database and repeat your command.
WARNING:  terminating connection because of crash of another server process
DETAIL:  The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.
HINT:  In a moment you should be able to reconnect to the database and repeat your command.
WARNING:  terminating connection because of crash of another server process
DETAIL:  The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.
HINT:  In a moment you should be able to reconnect to the database and repeat your command.
LOG:  all server processes terminated; reinitializing
LOG:  database system was interrupted; last known up at 2020-04-16 19:28:25 UTC
FATAL:  the database system is in recovery mode
LOG:  database system was not properly shut down; automatic recovery in progress
LOG:  record with zero length at 1/A5D88410
LOG:  redo is not required
LOG:  MultiXact member wraparound protections are now enabled
LOG:  database system is ready to accept connections
LOG:  autovacuum launcher started
LOG:  server process (PID 200) exited with exit code 255
LOG:  terminating any other active server processes
WARNING:  terminating connection because of crash of another server process
DETAIL:  The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.
HINT:  In a moment you should be able to reconnect to the database and repeat your command.
WARNING:  terminating connection because of crash of another server process
DETAIL:  The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.
HINT:  In a moment you should be able to reconnect to the database and repeat your command.
WARNING:  terminating connection because of crash of another server process
DETAIL:  The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.
HINT:  In a moment you should be able to reconnect to the database and repeat your command.
LOG:  all server processes terminated; reinitializing
LOG:  database system was interrupted; last known up at 2020-04-16 19:28:51 UTC
FATAL:  the database system is in recovery mode

Итак, я думаю, что в контейнере A процесс остановился во время выполнения команды psql, которая привела к неожиданному завершению работы сервера базы данных, я подозреваю, что это какое-то время ожидания соединения, но не уверен .. В журнале происходит быстрое завершение работы, и когда я запускаю bash, он сразу же завершается с ошибкой, как обсуждалось на этой странице , это могут быть некоторые автоматические обновления безопасности, включенные в PostgreSQL, но все же проверка причины ...

Кроме того, проблема в том, что он показывает только trapError без дополнительных подробностей, поэтому трудно выяснить причину, могу ли я спросить, есть ли какое-либо решение или какой-либо способ отладки в эту проблему?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...