Skip to content

[FIX] base_bg: commit before NOTIFY to avoid 10-min job delay#408

Closed
cos-adhoc wants to merge 1 commit into
ingadhoc:19.0from
adhoc-dev:19.0-h-119676-cos
Closed

[FIX] base_bg: commit before NOTIFY to avoid 10-min job delay#408
cos-adhoc wants to merge 1 commit into
ingadhoc:19.0from
adhoc-dev:19.0-h-119676-cos

Conversation

@cos-adhoc

Copy link
Copy Markdown
Contributor

bg_enqueue_records sent the PostgreSQL NOTIFY via _trigger_crons() before the transaction was committed. The cron runner woke up, found no enqueued jobs (not yet visible), and went back to sleep until the next scheduled tick (~10 min). Adding cr.commit() after all batch jobs are created guarantees visibility before the NOTIFY is sent.

@roboadhoc

Copy link
Copy Markdown
Contributor

Pull request status dashboard

@cos-adhoc cos-adhoc force-pushed the 19.0-h-119676-cos branch 4 times, most recently from e9e7389 to a21f549 Compare June 9, 2026 15:30
@nicomacr nicomacr requested a review from Copilot June 9, 2026 16:33

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Este PR busca evitar una condición de carrera al encolar trabajos en base_bg: el runner de crons puede despertarse antes de que los bg.job sean visibles en BD, provocando demoras de ~10 minutos hasta el siguiente tick.

Changes:

  • Se agrega un commit() antes de llamar a _trigger_crons() al finalizar bg_enqueue_records().
  • Se ajustan tests existentes para mockear cr.commit() y evitar commits reales durante TransactionCase.
  • Se agregan tests que validan el orden commit → trigger y que el commit ocurra una sola vez por lote.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
base_bg/models/base_bg.py Inserta cr.commit() antes de disparar crons al finalizar el encolado.
base_bg/tests/test_bg_job.py Actualiza mocks por el nuevo commit y agrega tests de orden/contaje del commit.

Comment thread base_bg/models/base_bg.py Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.

Comment thread base_bg/models/base_bg.py
Comment thread base_bg/tests/test_bg_job.py Outdated
Comment thread base_bg/tests/test_bg_job.py Outdated
Comment thread base_bg/tests/test_bg_job.py Outdated
Comment thread base_bg/tests/test_bg_job.py Outdated
Comment thread base_bg/tests/test_bg_job.py Outdated
Comment thread base_bg/tests/test_bg_job.py
@cos-adhoc cos-adhoc force-pushed the 19.0-h-119676-cos branch from 3af1abe to 6966c02 Compare June 10, 2026 14:22
@cos-adhoc cos-adhoc force-pushed the 19.0-h-119676-cos branch from 6966c02 to 706886e Compare June 10, 2026 14:29
@nicomacr

Copy link
Copy Markdown
Contributor

@roboadhoc r+ nobump

@roboadhoc roboadhoc closed this in 9b5584f Jun 10, 2026
@roboadhoc roboadhoc added the 18.1 label Jun 10, 2026
@roboadhoc roboadhoc deleted the 19.0-h-119676-cos branch June 10, 2026 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants