0078_add_superseded_at_to_background_jobs.py
python
sha256:388b0d5926748aed8e7b2941523f5fb2b6991d500eea4c3aac01c5e1e07d2d86
fix: fetch.mpack.prebuild rebuilds when superseded mid-build
Sonnet 5
minor
⚠ breaking
1 day ago
| 1 | """Add superseded_at to musehub_background_jobs |
| 2 | |
| 3 | musehub#108 (MWP9): dedup for self-coalescing job types (fetch.mpack.prebuild) |
| 4 | now treats an already-'running' row as covering a new trigger, on the |
| 5 | assumption that the running job will read fresh data before finishing. That |
| 6 | assumption breaks when the running job's data read already started before |
| 7 | the new trigger's write landed -- confirmed live: a bulk commit-signature |
| 8 | repair batch landed 20 fixes, but a concurrently-running prebuild job's read |
| 9 | only captured 1 of them, serving a stale cached mpack to the next clone |
| 10 | until a later, unrelated trigger happened to catch up. |
| 11 | |
| 12 | superseded_at lets enqueue_job flag a running row when a new trigger arrives |
| 13 | for it, and lets the job's own handler (process_fetch_mpack_prebuild_job) |
| 14 | check that flag after building and redo the build once more before marking |
| 15 | done, instead of finishing with stale coverage. |
| 16 | |
| 17 | Additive and nullable -- existing/historical rows get NULL (never superseded). |
| 18 | |
| 19 | Revision ID: 0078 |
| 20 | Revises: 0077 |
| 21 | """ |
| 22 | from __future__ import annotations |
| 23 | |
| 24 | from typing import Sequence, Union |
| 25 | |
| 26 | import sqlalchemy as sa |
| 27 | from alembic import op |
| 28 | |
| 29 | |
| 30 | # revision identifiers, used by Alembic. |
| 31 | revision: str = '0078' |
| 32 | down_revision: Union[str, None] = '0077' |
| 33 | branch_labels: Union[str, Sequence[str], None] = None |
| 34 | depends_on: Union[str, Sequence[str], None] = None |
| 35 | |
| 36 | |
| 37 | def upgrade() -> None: |
| 38 | op.add_column( |
| 39 | 'musehub_background_jobs', |
| 40 | sa.Column('superseded_at', sa.DateTime(timezone=True), nullable=True), |
| 41 | ) |
| 42 | |
| 43 | |
| 44 | def downgrade() -> None: |
| 45 | op.drop_column('musehub_background_jobs', 'superseded_at') |
File History
1 commit
sha256:388b0d5926748aed8e7b2941523f5fb2b6991d500eea4c3aac01c5e1e07d2d86
fix: fetch.mpack.prebuild rebuilds when superseded mid-build
Sonnet 5
minor
⚠
1 day ago