Skip to content

Wait for PostgreSQL readiness and recover failed setup - #1

Draft
pauljccode wants to merge 361 commits into
masterfrom
fix/database-startup-readiness
Draft

pauljccode wants to merge 361 commits into
masterfrom
fix/database-startup-readiness

Conversation

@pauljccode

@pauljccode pauljccode commented Oct 2, 2026 •

Copy link
Copy Markdown
Owner

Description

msfdb init can provision users before PostgreSQL is ready. If startup times out, a later init can mistake the unfinished database for a completed installation and skip provisioning.

Wait for PostgreSQL readiness using pg_ctl -w -t 60, apply authentication rules before startup, and track initialization through migration completion. Retry interrupted setup using saved settings without deleting existing data; leave incomplete initdb output and directories without initialization markers for inspection.

Production migrations fail without a Rails key or permission to write their schema dump into the installation. Give the migration subprocess a temporary key when SECRET_KEY_BASE is unset and discard its schema dump. Preserve rapid7#18442's Windows fix by leaving startup output uncaptured.

Verification

  1. Run SPEC_HELPER_LOAD_METASPLOIT=false bundle exec rspec spec/lib/msfdb_helpers/pg_ctl_spec.rb; expect 21 examples and no failures.
  2. In a disposable profile, run msfdb init --component database --use-defaults, then msfconsole -qx 'db_status; exit'; expect successful initialization and a connection.
  3. Repeat msfdb init; it should recognize the completed database without provisioning again.

Test evidence

The 21 helper specs pass on macOS and Windows. Recovery, fresh and repeated initialization also pass against installed runtimes, with 164 migrations verified by SQL and the installed schema unchanged.

All ten package jobs passed with Ruby 3.4.12 on macOS 14 arm64, macOS 15 x86_64, Windows Server 2022 and Linux. They build 809e1587 plus migration correction 711d40bb and verify its source digests. ARMv7 covers build and package health only.

AI Usage Disclosure

Codex assisted with implementation, tests, investigation and this description.

Upstream: rapid7#21964.

Nayeraneru and others added 6 commits September 29, 2026 16:55
Use pg_ctl wait mode and its exit status before creating database users.
A running postmaster alone does not establish connection readiness.
Keep process-based startup to avoid the Windows captured-pipe hang.

Stop initialization when startup fails, and cover readiness waiting,
startup failure, argument handling and initialization ordering in RSpec.
sfewer-r7 and others added 19 commits October 2, 2026 10:54
…ue to its NAT. This kills an idel shell session after 3 minutes, reproduced on a 13.1 target. Solution is to enable TCP keepalives, best I can tell there is no framework advance optiosn here we can reuse, so the module does it manually. MEterpreter sessiosn already sends idle pings so we only need this for sehll sessions.
Co-authored-by: Diego Ledda <diego_ledda@rapid7.com>
Co-authored-by: Diego Ledda <diego_ledda@rapid7.com>
…ighlty differently. tweak the loader to correctly reconstitute teh larger payload in thsi situation
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Add error handling for version parsing in Langflow exploit.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Handle version parsing errors with a rescue block.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Separate Bundler caches by runtime to prevent native gems built with
PHP libraries from being restored into Java or Python jobs.

Wait for automatic Git maintenance before Bundler clones its local
cache, avoiding concurrent commit-graph changes during hardlink checks.
The module docs for ibm_bigfix_sites_packages_enum (DOWNLOAD),
cisco_smart_install (SLEEP), wp_registrationmagic_sqli (COUNT) and
archmigrate (IGNORE_SYSTEM) stated defaults that differ from the
modules' register_options. synology_forget_passwd_user_enum documented
a USER_LIST option; the module registers USER_FILE.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jenkins-metasploit and others added 28 commits October 28, 2026 01:56
ENH: auxiliary module for Flowise Authentication Bypass CVE-2025-58434
Update the development runtime, Docker image and Windows setup
instructions to the patched Ruby release. Refresh setup-ruby version
manifests while retaining floating CI patch selectors.
…-10-23

Upgrade Framework Ruby runtime to 3.3.13
…fines

Add rubocop rule for redeclaring pre-existing options
Add SPIP password change IDOR privilege escalation module
…b-workflows-on-file-changes

Run additional github workflows on file changes
…ble_calling_cleanup

Removes redundant callings of cleanup
Add Portainer authenticated Docker API root RCE
…ows-aarch64-dll-generator

Add a Windows AArch64 PE DLL generator
Replace deprecated Rex UDP sendto with send in TFTP library and modules
…nt_rce

Add Exploit Module for GitLab RCE via CI Lint [CVE-2026-97229]
…ion-defaults

Fix option defaults and names in five module docs
Apply authentication before startup and retain initialization state until
configuration and migrations finish. Resume owned incomplete clusters
using their saved settings, without claiming unmarked data.

Propagate provisioning and migration failures and preserve existing data
on retry. Cover readiness, locking and recovery behavior.
@pauljccode pauljccode changed the title Wait for PostgreSQL readiness before database setup Wait for PostgreSQL readiness and recover failed setup Nov 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.