Fix file deletion command in recovery_1st_stage.sample.
authorTaiki Koshino <koshino@sraoss.co.jp>
Wed, 10 Sep 2025 04:33:23 +0000 (13:33 +0900)
committerTaiki Koshino <koshino@sraoss.co.jp>
Wed, 10 Sep 2025 04:33:23 +0000 (13:33 +0900)
In the recovery_1st_stage script, the file deletion command has been modified.
Previously, files under ARCHIVEDIR were deleted using "rm *", but when the total size of the target files exceeded ARG_MAX, it resulted in an "Argument list too long" error and caused the recovery_1st_stage script to fail.
By switching to the find command to delete files one by one, this error is avoided.

Discussion: https://github.com/pgpool/pgpool2/issues/94
Backpatch-through: v4.2

src/sample/scripts/recovery_1st_stage.sample

index 68e17d2ef961aebd7d33a8af71aef77fadba3271..fad0476c3516bea944ddcabcdfe9758c3adbd817 100755 (executable)
@@ -50,8 +50,8 @@ ssh -T ${SSH_OPTIONS} ${POSTGRESQL_STARTUP_USER}@$DEST_NODE_HOST "
 
     set -o errexit
 
-    [ -d \"${DEST_NODE_PGDATA}\" ] && rm -rf ${DEST_NODE_PGDATA}
-    [ -d \"${ARCHIVEDIR}\" ] && rm -rf ${ARCHIVEDIR}/*
+    [ -d \"${DEST_NODE_PGDATA}\" ] && rm -rf \"${DEST_NODE_PGDATA}\"
+    [ -d \"${ARCHIVEDIR}\" ] && find \"${ARCHIVEDIR}\" -type f -exec rm -f {} \;
 
     ${PGHOME}/bin/pg_basebackup -h $PRIMARY_NODE_HOST -U $REPLUSER -p $PRIMARY_NODE_PORT -D $DEST_NODE_PGDATA -X stream