Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Retry PUT 409 errors - delete and re-create event#964

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
telotortium wants to merge5 commits intopimutils:main
base:main
Choose a base branch
Loading
fromtelotortium:patch-1

Conversation

@telotortium
Copy link
Contributor

Attempt to address#963

I would appreciate a code review here - there might be a more elegant way to address this problem, but it works for my (very limited) use case.

Comment on lines 590 to 604
try:
href,etag=awaitself._put(self._normalize_href(href),item,etag)
exceptaiohttp.ClientResponseErrorase:
ife.status==409:
dav_logger.debug("Conflict, will delete old event and recreate it.")
awaitself.delete(self._normalize_href(href),None)
dav_logger.debug("Now trying again")
href,etag=awaitself._put(self._normalize_href(href),item,None)
else:
raisee
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This is not correct, 409 indicates that the server's copy of the item has changed since we last read it. Deleting-and-then-updating is essentially overwriting the conflicting copy, effectively resulting in data loss.

Maybe this is happening due to race conditions with concurrent edits? In such cases, the correct thing to do is run the sync again.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

In my case, I have the following~/.config/vdirsyncer/config:

[general]status_path = "~/.cache/vdirsyncer/status/"[storage caldav]type = "caldav"url = # redactedusername = # redactedpassword = # redactedread_only = trueitem_types = ["VEVENT"][storage gcal]type = "google_calendar"token_file = "~/.cache/vdirsyncer/gcal_robert_work.token"client_id = # redactedclient_secret = # redacteditem_types = ["VEVENT"][pair caldav_to_gcal]a = "caldav"b = "gcal"# Robert work (new)collections = [["caldav_to_gcal", "a_calendar_id", "b_calendar_id@group.calendar.google.com"]]conflict_resolution = "a wins"partial_sync = "ignore"

So in my case, since my caldav server is set to read-only and I have conflict resolution set toa wins, I actually don't care about the old event, and I'm completely fine with deleting it.

makuser reacted with thumbs up emoji
Comment on lines 604 to 618
try:
rv=awaitself._put(href,item,None)
exceptaiohttp.ClientResponseErrorase:
ife.status==409:
dav_logger.debug("Conflict, will delete old event and recreate it.")
awaitself.delete(href,None)
dav_logger.debug("Now trying again")
rv=awaitself._put(href,item,None)
else:
raisee
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Same comment as above.

else:
rv.append((href,Item(raw),etag))
forhrefinhrefs_left:
raiseexceptions.NotFoundError(href)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

get_multi receives a set of ids and currently returns items with those ids. In this case, one of them is missing -- but callers of this function will expect it to be returned.

I understand the rationale here, but I've an impression that this change will break things for other places usingget_multi.

@telotortium
Copy link
ContributorAuthor

@WhyNotHugo Thanks for your comments. I agree that I need to figure out how to make these changes more correct before merging, but I don't understand CalDAV or the code well enough to know what I need to do. These hacks are just what I need to get the sync in my configuration working.

@WhyNotHugo
Copy link
Member

A few tests are stil failing:https://builds.sr.ht/~whynothugo/job/776820#task-test-134

@g0rdonL

This comment was marked as off-topic.

telotortiumand others added3 commitsMarch 14, 2023 17:27
Attempt to addresspimutils#963I would appreciate a code review here - there might be a more elegant way to address this problem, but it works for my (very limited) use case.
Rather, just log them. This allows my calendar sync to continue to workeven if some of the hrefs can't be retrieved. In my case, one of thehrefs on my calendar was always returning a 404, so I want to skip it.
@telotortiumtelotortiumforce-pushed thepatch-1 branch 3 times, most recently from2b0af6b to3017744CompareMarch 15, 2023 00:41
@WhyNotHugo
Copy link
Member

Basically each time that vdirsyncer reads an event, we also get anEtag, which can be though of as a version identifier. TheEtag for an event changes each time that its content changes. When vdirsyncer tries to delete or alter an event, itspecifies "only if the Etag is equal to XXX". This avoids deleting an event if someone else has modified it after vdirsyncer last read it.

A 409 error means that we tried a write operation on an event assuming it had not changed, but ithas changed. If this keeps happening over and over, it likely means that there is an issue elsewhere in the logic. But in the general case, ignoring a 409 error means that you're overwriting or deleting files which have been modified by someone else, and will result in a data loss.

I honestly haven't looked deeply into the cause of this bug because it sounds very non-trivial, and I'd rather focus energy on the rewrite which should either not have this bug, or be a lot easier to debug.

@marc1uk
Copy link

I'm also having this issue. As with@telotortium, I also have vdirsyncer configured for 'remote wins', and I don't understand why this is not being handled by that mechanism.

When vdirsyncer tries to delete or alter an event, it specifies "only if the Etag is equal to XXX". This avoids deleting an event if someone else has modified it after vdirsyncer last read it.
...
In the general case, ignoring a 409 error means that you're overwriting or deleting files which have been modified by someone else, and will result in a data loss.

This Etag check seems redundant with an A/B wins configuration - it doesn't matter whether the event has been modified since last read, it's about to be overwritten anyway. Yes, this results in data loss, but that's been specifically requested by the user config.

This may be a complex issue to resolve for a more general merge situation, but for the time being this completely breaks synchronization.Some workaround is needed to get the system back on its feet - even if that means data loss.

makuser and WhyNotHugo reacted with thumbs up emoji

@marc1uk
Copy link

i added some comments on reproducing this issue over in#963

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@WhyNotHugoWhyNotHugoWhyNotHugo left review comments

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@telotortium@WhyNotHugo@g0rdonL@marc1uk

[8]ページ先頭

©2009-2025 Movatter.jp