Cloud Run -Does a trigger on "google.cloud.storage.object.v1.finalized" force a run on every object?

I’m looking for confirmation on some behaviour I’m seeing.

I have a 2nd gen Cloud Run function set to trigger on “google.cloud.storage.object.v1.finalized” in a particular bucket. That bucket happened to have 3 files in there already that hadn’t been moved due to past failures & I hadn’t cleared them out. When I dropped a new file into the bucket the Cloud Run function was initiated 3 times to run on that one new file (the event.data[‘name’] was the same for each event). When I cleared out the old files, the Cloud Run only ran once.

Is this expected behaviour? If so, why?

Hi @mdale9 ,

Welcome to Google Cloud Community!

This behavior can be expected when files are updated multiple times before being deleted, triggering multiple finalize events for each update. In your case, the old files likely went through several updates before removal, causing repeated triggers, whereas the new file was processed only once, as expected. The Cloud Storage finalized event is sent via Eventarc which uses Pub/Sub to trigger Cloud Run.

When a new event is published, Eventarc attempts to deliver it at-least-once to the target service. However, if there are pending or unacknowledged events, Eventarc may retry or batch them, which can lead to what appears to be duplicated events during delivery. Especially if, duplicate events can occur if there was a backlog from previous errors (like the 3 old files), or a temporary failure in delivery or acknowledgment, or if the same event was retried multiple times due to the acknowledgment didn’t reach the backend, even if your function processed it successfully. So even though you only dropped one new file, it’s possible that previously undelivered events were retried or that Eventarc misinterpreted the state and re-emitted the same new file’s event multiple times for that file.

If you need further assistance with your project, feel free to reach out to Google Cloud Support at any time.

Was this helpful? If so, please accept this answer as “Solution”. If you need additional assistance, reply here within 2 business days and I’ll be happy to help.