Re: Atomic Operations?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 12/24/2016 08:55 AM, Misa wrote:
I'm using a different scheme (might be suboptimal in your case).

I store object version id in object attributes. Every update increases version number. So the update first reads object version from rados and then creates transaction like this

```python
wop = ctx.write_op_create()
wop.assert_exists()
wop.cmpxattr('version', rados.CmpXattrOp.eq, current_version)
wop.setxattr('version', new_version)
wop.write_full(data)
```

If it fails because of the condition, I just retry. Creating new object is similar

```
wop = ctx.write_op_create()
wop.create(True)
wop.setxattr('version', version)
wop.write_full(data)
```

That looks like the kind of thing I want to do.

A question: The write_op_create() starts transaction, and the write_full() closes it? And you get a Python exception if there is a problem?

Cool.

Examples are so helpful.

Thanks,

-kb

_______________________________________________
ceph-users mailing list
ceph-users@xxxxxxxxxxxxxx
http://lists.ceph.com/listinfo.cgi/ceph-users-ceph.com



[Index of Archives]     [Information on CEPH]     [Linux Filesystem Development]     [Ceph Development]     [Ceph Large]     [Linux USB Development]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [xfs]


  Powered by Linux