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:
pg_ctl -l logfile startopens the log file for writing- postgres subprocess starts and does crash recovery
- During recovery, postgres tries to fsync the entire pgdata directory
- This includes the log file that pg_ctl still has open → sharing violation
- 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dc409630918e7434025782be6a9a478d6cac18c79b55a83c442064ae6d873e91
|
|
| MD5 |
8d1d9305634c6308a827860f0f769d87
|
|
| BLAKE2b-256 |
75afabb31e4db68509040842e3f498c394a624105ebe0525606bfffc60984769
|
Provenance
The following attestation bundles were made for fitz_pgserver-0.1.5.tar.gz:
Publisher:
publish.yml on yafitzdev/fitz-pgserver
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fitz_pgserver-0.1.5.tar.gz -
Subject digest:
dc409630918e7434025782be6a9a478d6cac18c79b55a83c442064ae6d873e91 - Sigstore transparency entry: 872449190
- Sigstore integration time:
-
Permalink:
yafitzdev/fitz-pgserver@4090e6f46d24d699b92bb8b89d57f05cf8a94e1e -
Branch / Tag:
refs/tags/v0.1.5 - Owner: https://github.com/yafitzdev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4090e6f46d24d699b92bb8b89d57f05cf8a94e1e -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e2459737398b59140f4aeb5666eeadf1e8d22f7df77c305ad2924754dec7bab8
|
|
| MD5 |
53b3ceff8582db4b2e23b28067e285b0
|
|
| BLAKE2b-256 |
0692ea063556e81c7db91d0081dac564d69e9852b5d5946340a79c310bf21d5a
|
Provenance
The following attestation bundles were made for fitz_pgserver-0.1.5-py3-none-any.whl:
Publisher:
publish.yml on yafitzdev/fitz-pgserver
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fitz_pgserver-0.1.5-py3-none-any.whl -
Subject digest:
e2459737398b59140f4aeb5666eeadf1e8d22f7df77c305ad2924754dec7bab8 - Sigstore transparency entry: 872449194
- Sigstore integration time:
-
Permalink:
yafitzdev/fitz-pgserver@4090e6f46d24d699b92bb8b89d57f05cf8a94e1e -
Branch / Tag:
refs/tags/v0.1.5 - Owner: https://github.com/yafitzdev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4090e6f46d24d699b92bb8b89d57f05cf8a94e1e -
Trigger Event:
release
-
Statement type: