Skip to main content

Fork of pgserver with Windows crash recovery fix - self-contained PostgreSQL for Python apps

Project description

fitz-pgserver

Fork of pgserver with Windows crash recovery fix.

Why this fork?

On Windows, when PostgreSQL crashes or is killed (e.g., via Ctrl+C), the recovery process can fail with a "sharing violation" error on the log file. This happens because:

  1. pg_ctl -l logfile start opens the log file for writing
  2. postgres subprocess starts and does crash recovery
  3. During recovery, postgres tries to fsync the entire pgdata directory
  4. This includes the log file that pg_ctl still has open → sharing violation
  5. postgres retries for 30 seconds before proceeding

The Fix

Put the log file in the system temp directory (outside pgdata):

# Before (pgserver):
self.log = self.pgdata / 'log'

# After (fitz-pgserver):
temp_dir = Path(tempfile.gettempdir())
self.log = temp_dir / f'pgserver_log.{uuid.uuid4().hex[:8]}'

By putting the log file outside pgdata, postgres doesn't try to fsync it during recovery, avoiding the sharing violation entirely.

Installation

pip install fitz-pgserver

Usage

Drop-in replacement for pgserver:

# Instead of: import pgserver
import fitz_pgserver as pgserver

db = pgserver.get_server("./my_pgdata")
uri = db.get_uri()
# Use uri with psycopg, SQLAlchemy, etc.

Performance

Scenario pgserver fitz-pgserver
Normal startup ~2s ~2s
First-time init ~10-13s ~10-13s
Crash recovery ~33s (data preserved but slow) ~1-2s (28x faster)

The massive improvement in crash recovery is because we avoid the 30-second sharing violation retry loop.

License

Apache 2.0 (same as original pgserver)

Credits

Original pgserver by Oscar Moll.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fitz_pgserver-0.1.5.tar.gz (15.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fitz_pgserver-0.1.5-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

Details for the file fitz_pgserver-0.1.5.tar.gz.

File metadata

  • Download URL: fitz_pgserver-0.1.5.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fitz_pgserver-0.1.5.tar.gz
Algorithm Hash digest
SHA256 dc409630918e7434025782be6a9a478d6cac18c79b55a83c442064ae6d873e91
MD5 8d1d9305634c6308a827860f0f769d87
BLAKE2b-256 75afabb31e4db68509040842e3f498c394a624105ebe0525606bfffc60984769

See more details on using hashes here.

Provenance

The following attestation bundles were made for fitz_pgserver-0.1.5.tar.gz:

Publisher: publish.yml on yafitzdev/fitz-pgserver

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fitz_pgserver-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: fitz_pgserver-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 16.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fitz_pgserver-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 e2459737398b59140f4aeb5666eeadf1e8d22f7df77c305ad2924754dec7bab8
MD5 53b3ceff8582db4b2e23b28067e285b0
BLAKE2b-256 0692ea063556e81c7db91d0081dac564d69e9852b5d5946340a79c310bf21d5a

See more details on using hashes here.

Provenance

The following attestation bundles were made for fitz_pgserver-0.1.5-py3-none-any.whl:

Publisher: publish.yml on yafitzdev/fitz-pgserver

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page