我在Ubuntu 10.04.2 LTS(主要和备用)上有PostgreSQL 9.1.3流式复制设置。复制通过流式基础备份(pg_basebackup
)进行初始化。 restore_command
脚本尝试使用rsync
从远程归档位置获取所需的WAL归档。PostgreSQL 9.1流式复制restore_command:退出代码255的特殊含义?
一切工作像documentation描述的,当restore_command设置脚本失败,退出代码<> 255:
At startup, the standby begins by restoring all WAL available in the archive location, calling restore_command. Once it reaches the end of WAL available there and restore_command fails, it tries to restore any WAL available in the pg_xlog directory. If that fails, and streaming replication has been configured, the standby tries to connect to the primary server and start streaming WAL from the last valid record found in archive or pg_xlog. If that fails or streaming replication is not configured, or if the connection is later disconnected, the standby goes back to step 1 and tries to restore the file from the archive again. This loop of retries from the archive, pg_xlog, and via streaming replication goes on until the server is stopped or failover is triggered by a trigger file.
但当的restore_command脚本失败,退出代码为255(因为从失败的rsync的退出代码调用由脚本返回)服务器进程,出现以下错误死亡:
2012-05-09 23:21:30 CEST - @ LOG: database system was interrupted; last known up at 2012-05-09 23:21:25 CEST
2012-05-09 23:21:30 CEST - @ LOG: entering standby mode
rsync: connection unexpectedly closed (0 bytes received so far) [Receiver]
rsync error: unexplained error (code 255) at io.c(601) [Receiver=3.0.7]
2012-05-09 23:21:30 CEST - @ FATAL: could not restore file "00000001000000000000003D" from archive: return code 65280
2012-05-09 23:21:30 CEST - @ LOG: startup process (PID 8184) exited with exit code 1
2012-05-09 23:21:30 CEST - @ LOG: aborting startup due to startup process failure
所以我的问题是现在:这是一个错误,还是有它的行吟诗人失踪的退出码255特殊的意义rwise出色的文档,或者我在这里错过了其他的东西?
,我不是做这个的答案,现在,因为我没有时间来检查源代码来确认,直到后来还是明天,但我的记忆是,在恢复过程中应用WAL文件时,非-zero退出代码小于255表示“失败,但继续尝试”,而255(或更高)表示“失败严重;放弃”。您可能需要调整脚本以返回rsync失败的较小退出代码。 – kgrittn
@kgrittn:谢谢,我在想这样的事情,但我找不到有关退出代码255的特殊含义的任何文档,我不知道在源代码中查找它的位置。 – tscho
呃,它花了一段时间,但这又浮现为我不得不处理的一个问题,我的评论在这里被引用,所以我查了一下并发布了一个包含细节的答案。这一次我会看到有关将文件写入文档的方法...... – kgrittn