Skip to content

fix(sync): keep the catalog writer alive for the VACINACAO phase - #368

Open
devgtv wants to merge 1 commit into
AlertaDengue:mainfrom
devgtv:fix/sync-writer-queue-vacinacao-deadlock
Open

devgtv wants to merge 1 commit into
AlertaDengue:mainfrom
devgtv:fix/sync-writer-queue-vacinacao-deadlock

Conversation

@devgtv

@devgtv devgtv commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

fix(sync): keep the catalog writer alive for the VACINACAO phase

run() terminated the single catalog writer by queueing workers
sentinels on write_queue in the "no producers" branch, then computed
writers_total = max(1, len(gov_workers_tasks)) -- which is 1 when there
are no gov items. The writer breaks on the first sentinel it sees, so it
exited before the trailing phases ran.

VACINACAO items are deliberately deferred to a serial phase that pushes
onto write_queue after the concurrent drain, and the retry pass does the
same. With neither of those consumers alive, their entries had no reader:
the parquet was uploaded to S3 but no catalog row was written and no
SyncOutcome was emitted, so the artifact stayed invisible to PySUS. Once
the bounded queue (maxsize=workers*2) filled, the put blocked forever and
the run hung with no timeout.

The branch was also a copy-paste of the one above it, which correctly
sends sentinels to raw_queue to stop the processors.

Sent the writer's single shutdown sentinel at the end of run(), right
before awaiting the writer, and set writers_total to 1 to match the one
consumer that actually exists.

Test added for a VACINACAO-only run: it asserts every deferred item is
reported as uploaded and reaches the catalog. It fails with 0 uploaded
against the previous code.


This is a re-submission of #351, which was closed without review. The
workflow runs on that PR sat in action_required for three days and then
expired unapproved, so CI never went green.

This workflow run required approval but was not approved before it expired.

The fix is unchanged; the branch was rebased onto the current main, where
the suite passes (1779 passed, 6 skipped) and black/isort/flake8 are clean.

run() terminated the single catalog writer by queueing `workers`
sentinels on write_queue in the "no producers" branch, then computed
writers_total = max(1, len(gov_workers_tasks)) -- which is 1 when there
are no gov items. The writer breaks on the first sentinel it sees, so it
exited before the trailing phases ran.

VACINACAO items are deliberately deferred to a serial phase that pushes
onto write_queue after the concurrent drain, and the retry pass does the
same. With neither of those consumers alive, their entries had no reader:
the parquet was uploaded to S3 but no catalog row was written and no
SyncOutcome was emitted, so the artifact stayed invisible to PySUS. Once
the bounded queue (maxsize=workers*2) filled, the put blocked forever and
the run hung with no timeout.

The branch was also a copy-paste of the one above it, which correctly
sends sentinels to raw_queue to stop the processors.

Sent the writer's single shutdown sentinel at the end of run(), right
before awaiting the writer, and set writers_total to 1 to match the one
consumer that actually exists.

Test added for a VACINACAO-only run: it asserts every deferred item is
reported as uploaded and reaches the catalog. It fails with 0 uploaded
against the previous code.
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@9db5915). Learn more about missing BASE report.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #368   +/-   ##
=======================================
  Coverage        ?   97.20%           
=======================================
  Files           ?      180           
  Lines           ?    23310           
  Branches        ?        0           
=======================================
  Hits            ?    22658           
  Misses          ?      652           
  Partials        ?        0           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants