GCP storage - lock object/file stored in GCP bucket

867 Views Asked by At

I am getting a data file from source system. once file received in GCP bucket we start processing that file. How to lock this file till the processing is completed? so no other file processor (app) can process this file if it is locked/in processing.

1

There are 1 best solutions below

0
Roopa M On

There is no way to lock a Google Cloud Storage bucket or object. But , You can use Preconditions to prevent race conditions.

Preconditions are often used to prevent race conditions in mutating requests, such as uploads, deletes, or metadata updates. Race conditions can arise when the same request is sent repeatedly or when independent processes each attempt to modify the same resource. See Examples of race conditions and data corruption for more information. Preconditions are also often used when retrieving object metadata and data in successive requests, to ensure the object did not change in the time between the two requests.

You may have a lock at this thread