Skip to content

Fix duplicate webhook paused alerts - #12946

Closed
kush2439p wants to merge 4 commits into
appwrite:mainfrom
kush2439p:codex/fix-webhook-paused-alert-race
Closed

kush2439p wants to merge 4 commits into
appwrite:mainfrom
kush2439p:codex/fix-webhook-paused-alert-race

Conversation

@kush2439p

@kush2439p kush2439p commented Jul 23, 2026 •

Copy link
Copy Markdown

Summary

Prevents concurrent failed webhook deliveries from sending duplicate paused notifications without losing the alert when notification enqueueing fails.

Root cause

Each worker incremented attempts and checked a stale webhook document independently, so multiple workers could cross the threshold and send the same alert. The pause state was then committed before notification enqueueing, and the enqueue result was ignored, which could permanently suppress a failed alert.

Changes

  • Lock the webhook row while incrementing attempts and deciding the enabled-to-disabled transition.
  • Enqueue the paused notification before committing enabled: false; a rejected enqueue rolls the transaction back for retry.
  • Reuse a stable pause-cycle deduplication key across transaction retries.
  • Verify every failure transition requests a row lock, stale messages produce one alert, and enqueue failure preserves the enabled state and attempt count.

Verification

  • git diff --check passes.
  • Targeted PHPUnit execution is locally blocked: PHP is unavailable, and Docker Desktop became unresponsive while building the repository's official test image, including after one restart.

Fixes #12944

@kush2439p

Copy link
Copy Markdown
Author

Hi! This PR attempts to fix the duplicate “webhook paused” notifications caused by concurrent failed deliveries. I added a transaction around the threshold transition so only the worker that actually pauses the webhook sends the alert, along with a regression test for stale concurrent messages.
I’d really appreciate any feedback on the approach or testing coverage. Thank you for reviewing!

Added a test for failure threshold handling of stale concurrent webhook messages, ensuring only one alert is sent and the webhook is disabled after multiple attempts.
@greptile-apps

greptile-apps Bot commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR serializes webhook failure-threshold updates and rolls back the pause when notification publication reports failure.

  • Locks the webhook row while incrementing attempts and deciding the enabled-to-disabled transition.
  • Uses a stable pause-cycle key for notification deduplication.
  • Adds coverage for stale webhook messages and notification enqueue failure.

Confidence Score: 5/5

The PR appears safe to merge because no blocking failure remains.

No blocking failure remains.

Important Files Changed

Filename Overview
src/Appwrite/Platform/Workers/Webhooks.php Moves failure accounting and pause selection into a row-locked transaction, checks notification enqueue results, and preserves a stable deduplication key across retries.
tests/unit/Platform/Workers/WebhooksTest.php Adds unit coverage for stale webhook documents, enqueue rollback behavior, and locking-read invocation.

Fix All in Greploop

Reviews (2): Last reviewed commit: "fix: preserve webhook pause alert retrie..." | Re-trigger Greptile

@kush2439p

Copy link
Copy Markdown
Author

Hi maintainers, following up on this PR since it has not yet received a human review. The concurrency fix and regression tests are ready, and the latest automated review reports no blocking findings. I am happy to make any requested adjustments. Thank you.

@HarshMN2345

Copy link
Copy Markdown
Member

Closing as stale since there has been no activity for a while. Thanks for the contribution! If this is still relevant, feel free to rebase on main and reopen.

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.

Concurrent webhook failures can send duplicate "webhook paused" alerts at the retry threshold

2 participants