GoogleChrome / GoogleChrome/webstatus.dev

[ENHANCEMENT] Use unique UUIDs for Worker Locking in Event Producer instead of Trigger ID

Open
#2,123 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Go
Stars
254
Forks
62
Avg merge
1d 10h
Merged PRs (30d)
64

Description

Currently, the `EventProducer` uses the incoming `triggerID` (from the Pub/Sub message ID or Cloud Event ID) as the `workerID` when acquiring the `SavedSearchState` lock in Spanner.

**The Problem:**
This approach is unsafe for distributed locking. If a worker process stalls (e.g., GC pause) and the lock expires, a second worker might pick up the *retry* of the same message. Since the `triggerID` is identical, the second worker acquires the lock with the *same* ID. If the first "zombie" worker wakes up, the database cannot distinguish between them because they share the same ID. This defeats the fencing token protection and could lead to data corruption (Split Brain) if the zombie worker overwrites the state.

**The Solution:**
The `ProcessSearch` method in the `EventProducer` must be updated to generate a new, random UUID (v4) at the start of every execution. This UUID should be used exclusively as the `workerID` for locking operations:

1. `TryAcquireSavedSearchStateWorkerLock`
2. `PublishSavedSearchNotificationEvent` (for the fencing check)
3. `ReleaseSavedSearchStateWorkerLock`

**Acceptance Criteria:**

* `ProcessSearch` generates a unique `workerUUID`.
* The `workerUUID` is passed to the lock acquisition method instead of `triggerID`.
* The `workerUUID` is passed to the publish/release methods to verify ownership.
* The `triggerID` is maintained for tracing and as the `EventID` for the resulting notification, but it is **not** used for the lock identity.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.