Skip to content

rgw: fix data corruption when race condition - #4752

Merged
yehudasa merged 1 commit into
ceph:masterfrom
wuxingyi:wip-11749
Jun 12, 2015
Merged

yehudasa merged 1 commit into
ceph:masterfrom
wuxingyi:wip-11749

Conversation

@wuxingyi

Copy link
Copy Markdown
Contributor

We should delete the object in the multipart namespace lastly to prevent a previous upload
wrongly deleting objects belong to the following upload.

Fixes: #11749

@wuxingyi

Copy link
Copy Markdown
Contributor Author

hi, @yehudasa,here is my logic:
There are two kinds of race conditon.
The first is, When the first upload begin to delete its rados objects(because of imcomplete uploading), it may delete the object with multipart namespace, then the second upload will not encounter an EEXIST and start with the original suffix(with "2/"), which will be dangerous becase the first upload will keep delete its rados objects which the second upload has just written. so we must make sure the object with "multipart" namespace would be deleted last. The second race conditon is, if the second upload entered the branch of EEXIST, it will start with another suffix, but if we delete the object with "multipart" namespace here, if a third upload come and found it's safe to begin with the original suffix(because the object with "multipart" namespace has been deleted by the second upload), there is a possibility that the first upload is still deleting it's rados objects. In my tests, such race condition happened occasionally.
I think remove from written_objs map is helpful to solve the second kind of race conditon, but to avoid the first kind of race condition, we should have a mechanism to delete the object "with multipart" namespace last.
I am not quite familiar with gateway, did I miss something?

@yehudasa

Copy link
Copy Markdown
Member

@wuxingyi oh, I think I see where the issue is. The problem is that we remove the 'tail' after the 'head' (the object in the 'multipart' namespace), and the head is the gatekeeper. I think that an easier fix would be to first remove the tails, and only then the heads. What do you think?

@wuxingyi

Copy link
Copy Markdown
Contributor Author

@yehudasa ,I tried simply by using reverse iterator to delete the objects(on giant-0.87), but I found sometimes the object with "mutipart" namespace is not necessarily the first object of the array, so I did more work to make sure the "multipart" object was deleted last.
This patch is based on giant-0.87, I tested the reverse iterator idea with upstream, found nothing wrong. Do you think it's safe to use reverse iterator?

We should delete the object in the multipart namespace lastly to prevent a previous upload
wrongly deleting objects belong to the following upload.

Fixes: #11749
Signed-off-by: wuxingyi <[email protected]>
@wuxingyi

Copy link
Copy Markdown
Contributor Author

@yehudasa , could you please review it again? thanks :)

yehudasa added a commit that referenced this pull request Jun 12, 2015
rgw: fix data corruption when race condition

Reviewed-by: Yehuda Sadeh <[email protected]>
@yehudasa
yehudasa merged commit 69989ff into ceph:master Jun 12, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants