fix: document SQLite synchronous=0 pragma in db_engine.py (#20)
Add explanatory comment clarifying that synchronous=OFF is a dev-only trade-off (production uses PostgreSQL), and describing the crash-corruption risk and how WAL mode partially mitigates it. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
761c0a6dab
commit
d43aa7079f
@ -30,7 +30,15 @@ if DATABASE_TYPE.lower() == "postgresql":
|
|||||||
autorollback=True, # Automatically rollback failed transactions
|
autorollback=True, # Automatically rollback failed transactions
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
# Default SQLite configuration for local development
|
# SQLite configuration for local development only.
|
||||||
|
# Production always uses PostgreSQL (see DATABASE_TYPE env var).
|
||||||
|
#
|
||||||
|
# synchronous=0 (OFF): SQLite skips fsync() after every write, maximising
|
||||||
|
# throughput at the cost of durability — a hard crash could corrupt the DB.
|
||||||
|
# This is an acceptable trade-off in dev where data loss is tolerable and
|
||||||
|
# write speed matters. WAL journal mode reduces (but does not eliminate)
|
||||||
|
# the corruption window by keeping the main database file consistent while
|
||||||
|
# writes land in the WAL file first.
|
||||||
db = SqliteDatabase(
|
db = SqliteDatabase(
|
||||||
"storage/pd_master.db",
|
"storage/pd_master.db",
|
||||||
pragmas={"journal_mode": "wal", "cache_size": -1 * 64000, "synchronous": 0},
|
pragmas={"journal_mode": "wal", "cache_size": -1 * 64000, "synchronous": 0},
|
||||||
@ -925,7 +933,13 @@ CardPosition.add_index(pos_index)
|
|||||||
|
|
||||||
if not SKIP_TABLE_CREATION:
|
if not SKIP_TABLE_CREATION:
|
||||||
db.create_tables(
|
db.create_tables(
|
||||||
[BattingCard, BattingCardRatings, PitchingCard, PitchingCardRatings, CardPosition],
|
[
|
||||||
|
BattingCard,
|
||||||
|
BattingCardRatings,
|
||||||
|
PitchingCard,
|
||||||
|
PitchingCardRatings,
|
||||||
|
CardPosition,
|
||||||
|
],
|
||||||
safe=True,
|
safe=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user