Skip to content

Commit 64fb289

Browse files
committed
fix: postgresql.conf settings replacing
1 parent 5288405 commit 64fb289

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

internal/branches/service.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ func (s *Service) executeBranchCreation(ctx context.Context, config *models.Conf
244244
if strings.Contains(output, "BRANCHD_ERROR:DATABASE_NOT_READY") {
245245
errorMsg := extractErrorMessage(output)
246246
s.logger.Info().Str("branch_name", params.BranchName).Str("error_detail", errorMsg).Msg("Branch creation failed: source database not ready")
247-
return nil, fmt.Errorf("instance is still in initial recovery. Please wait a few minutes and try again")
247+
return nil, fmt.Errorf("restore is not accepting connections")
248248
}
249249
if strings.Contains(output, "BRANCHD_ERROR:RESTORE_NOT_RUNNING") {
250250
errorMsg := extractErrorMessage(output)

internal/workers/crunchy_bridge_restore.sh

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,18 @@ die() {
2828
log "ERROR: $1" >&2
2929

3030
# Stop PostgreSQL service if it was started
31-
if systemctl is-active --quiet "${SERVICE_NAME}" 2>/dev/null; then
32-
log "Stopping PostgreSQL service..."
33-
sudo systemctl stop "${SERVICE_NAME}" 2>/dev/null || true
34-
fi
31+
# if systemctl is-active --quiet "${SERVICE_NAME}" 2>/dev/null; then
32+
# log "Stopping PostgreSQL service..."
33+
# sudo systemctl stop "${SERVICE_NAME}" 2>/dev/null || true
34+
# fi
3535

3636
# Remove systemd service
37-
if [ -f "/etc/systemd/system/${SERVICE_NAME}.service" ]; then
38-
log "Removing systemd service..."
39-
sudo systemctl disable "${SERVICE_NAME}" 2>/dev/null || true
40-
sudo rm -f "/etc/systemd/system/${SERVICE_NAME}.service"
41-
sudo systemctl daemon-reload
42-
fi
37+
# if [ -f "/etc/systemd/system/${SERVICE_NAME}.service" ]; then
38+
# log "Removing systemd service..."
39+
# sudo systemctl disable "${SERVICE_NAME}" 2>/dev/null || true
40+
# sudo rm -f "/etc/systemd/system/${SERVICE_NAME}.service"
41+
# sudo systemctl daemon-reload
42+
# fi
4343

4444
# Destroy ZFS dataset if it was created
4545
# if sudo zfs list "${ZFS_DATASET}" >/dev/null 2>&1; then
@@ -159,11 +159,11 @@ PG_MAX_PREPARED_XACTS=$(sudo -u postgres grep -h "^max_prepared_transactions" "$
159159
PG_MAX_LOCKS_PER_XACT=$(sudo -u postgres grep -h "^max_locks_per_transaction" "${DATA_DIR}/postgresql.conf" 2>/dev/null | tail -1 | sed "s/.*=\s*['\"]*//" | sed "s/['\"].*//" || echo "64")
160160

161161
# Extract from conf.d files
162-
CONFD_MAX_CONNECTIONS=$(sudo -u postgres grep -h "^max_connections" "${DATA_DIR}/conf.d/"*.conf 2>/dev/null | tail -1 | sed "s/.*=\s*['\"]*//" | sed "s/['\"].*//" || echo "0")
163-
CONFD_MAX_WORKER_PROCESSES=$(sudo -u postgres grep -h "^max_worker_processes" "${DATA_DIR}/conf.d/"*.conf 2>/dev/null | tail -1 | sed "s/.*=\s*['\"]*//" | sed "s/['\"].*//" || echo "0")
164-
CONFD_MAX_WAL_SENDERS=$(sudo -u postgres grep -h "^max_wal_senders" "${DATA_DIR}/conf.d/"*.conf 2>/dev/null | tail -1 | sed "s/.*=\s*['\"]*//" | sed "s/['\"].*//" || echo "0")
165-
CONFD_MAX_PREPARED_XACTS=$(sudo -u postgres grep -h "^max_prepared_transactions" "${DATA_DIR}/conf.d/"*.conf 2>/dev/null | tail -1 | sed "s/.*=\s*['\"]*//" | sed "s/['\"].*//" || echo "0")
166-
CONFD_MAX_LOCKS_PER_XACT=$(sudo -u postgres grep -h "^max_locks_per_transaction" "${DATA_DIR}/conf.d/"*.conf 2>/dev/null | tail -1 | sed "s/.*=\s*['\"]*//" | sed "s/['\"].*//" || echo "0")
162+
CONFD_MAX_CONNECTIONS=$(sudo -u postgres grep -h "max_connections" "${DATA_DIR}/conf.d/"*.conf 2>/dev/null | grep -v "^\s*#" | tail -1 | sed "s/.*=\s*['\"]*//" | sed "s/['\"].*//" || echo "0")
163+
CONFD_MAX_WORKER_PROCESSES=$(sudo -u postgres grep -h "max_worker_processes" "${DATA_DIR}/conf.d/"*.conf 2>/dev/null | grep -v "^\s*#" | tail -1 | sed "s/.*=\s*['\"]*//" | sed "s/['\"].*//" || echo "0")
164+
CONFD_MAX_WAL_SENDERS=$(sudo -u postgres grep -h "max_wal_senders" "${DATA_DIR}/conf.d/"*.conf 2>/dev/null | grep -v "^\s*#" | tail -1 | sed "s/.*=\s*['\"]*//" | sed "s/['\"].*//" || echo "0")
165+
CONFD_MAX_PREPARED_XACTS=$(sudo -u postgres grep -h "max_prepared_transactions" "${DATA_DIR}/conf.d/"*.conf 2>/dev/null | grep -v "^\s*#" | tail -1 | sed "s/.*=\s*['\"]*//" | sed "s/['\"].*//" || echo "0")
166+
CONFD_MAX_LOCKS_PER_XACT=$(sudo -u postgres grep -h "max_locks_per_transaction" "${DATA_DIR}/conf.d/"*.conf 2>/dev/null | grep -v "^\s*#" | tail -1 | sed "s/.*=\s*['\"]*//" | sed "s/['\"].*//" || echo "0")
167167

168168
# Use MAX of both to ensure recovery requirements are met
169169
MAX_CONNECTIONS=$(max_value "$PG_MAX_CONNECTIONS" "$CONFD_MAX_CONNECTIONS")

0 commit comments

Comments
 (0)