Google Cloud Storage Transactions?

GCS does not seem to have any kind of transaction mechanism. Is it correct?

I would like to have a long term transaction. For example, it would be great if I could start the transaction and specify the expiration time (if it was not committed within X times, it will automatically roll back). Then I could use this handle to insert objects, layout, delete, etc., and if all goes well, issue isCommitPossible (), and if so, commit ().

Is it possible?

+6
source share
2 answers

Recording objects is transactional (either the complete object and its metadata are successfully recorded, and the object becomes visible, or it ceases to be visible). But there is no transaction mechanism spanning multiple GCS operations.

Mike

+7
source

Cloud storage client libraries offer a file-like object that Open () and Close () work with. If one operation can be transactional, then, theoretically, it should be possible to open one “lock file” for the duration of all other operations, only closing it when you finish will have all the other files.

In other words, you will need to write your processes in order to use the “lock file”, and thus, you could at least find out if all your files were written / read or if there were any errors. Whenever the next round of operations occurs, it simply looks for a lock file that matches the set of files written (you would need to organize your name, directory layout, etc., to make sense for this). If it exists, we can assume that the group of files was successfully recorded. If this does not exist, assume that something has happened (or that the process is not yet complete).

I really have not tested this. But I propose this as an idea for others who may be desperate to try.

0
source

All Articles