29 lines
1.0 KiB
Python
29 lines
1.0 KiB
Python
"""pool_starvation, row_lock_contention, poison_data -- phase-0-base-project-spec.md
|
|||
|
|
§7. All three are owned by `ledger`.
|
||
|
|
"""
|
||
|
|
from common.chaos_flags import is_enabled
|
||
|
|
from common.redis_client import redis_client
|
||
|
|
|
||
|
|
# Populated once by scripts/seed.py: account_id -> id of that account's one
|
||
|
|
# deliberately NULL-currency transaction (§8). A Redis hash lookup, not a
|
||
|
|
# `transactions` scan by account_id -- that column has no supporting index
|
||
|
|
# on purpose (§5), and the poison_data pathology shouldn't have to pay for a
|
||
|
|
# full-table seq scan on every single request just to find its own trigger.
|
||
|
|
POISON_TX_KEY = "poison:tx_by_account"
|
||
|
|
|
||
|
|
|
||
|
|
async def pool_starvation_enabled() -> bool:
|
||
|
|
return await is_enabled("pool_starvation")
|
||
|
|
|
||
|
|
|
||
|
|
async def row_lock_contention_enabled() -> bool:
|
||
|
|
return await is_enabled("row_lock_contention")
|
||
|
|
|
||
|
|
|
||
|
|
async def poison_data_enabled() -> bool:
|
||
|
|
return await is_enabled("poison_data")
|
||
|
|
|
||
|
|
|
||
|
|
async def find_poison_transaction_id(account_id: str) -> str | None:
|
||
|
|
return await redis_client.hget(POISON_TX_KEY, account_id)
|