Skip to content

lib/db: Check if sequences change when repairing metadata - #7770

Merged
imsodin merged 2 commits into
syncthing:mainfrom
imsodin:db/meta-repair-check-sequences
Jun 17, 2021
Merged

imsodin merged 2 commits into
syncthing:mainfrom
imsodin:db/meta-repair-check-sequences

Conversation

@imsodin

@imsodin imsodin commented Jun 16, 2021

Copy link
Copy Markdown
Member

Topic came up in #7726 (comment):

calmh:

[...] Those entries will have taken up a sequence number, removing them and doing a meta recalculation would rewind the sequence number which is not great.

imsodin:

That's a good point: Recalculating metadata and not resetting delta indexes seems like a dangerous thing to do in general. Even today where there should be no way the sequence number decreases when recalculating metadata, I think it would be better to ensure it doesn't (or reset delta indexes).

I added a step at the end of the db check/repair that compares meta-sequences for all devices between before and after repair. If any of them are changed, the respective index id is reset.

@calmh calmh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think it's overkill to drop index IDs for lower than expected remote IDs, it just means we didn't write the metadata record in time and will get duplicates of those updates (which should be fine...)? Anyway it might be nice with failure counters here as well so we can know what happens (and in which direction the problem was (lower/higher), maybe).

Comment thread lib/db/lowlevel.go Outdated
if err := deleteIndexID(protocol.LocalDeviceID); err != nil {
return err
}
l.Infoln("Local sequence changed while repairing - dropping delta indexes")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Might want to mention the folder in these messages as I guess it might happen for several folders if it happens at all

calmh
calmh previously approved these changes Jun 17, 2021
@imsodin

imsodin commented Jun 17, 2021

Copy link
Copy Markdown
Member Author

I think it's overkill to drop index IDs for lower than expected remote IDs, it just means we didn't write the metadata record in time and will get duplicates of those updates (which should be fine...)?

Should indeed be fine. I think it should not happen that we do write file infos to db, but not metadata, as we write both at the same time. However who knows what the actual db layer does.

@imsodin
imsodin merged commit aeca1fb into syncthing:main Jun 17, 2021
@imsodin
imsodin deleted the db/meta-repair-check-sequences branch June 17, 2021 11:53
@st-release st-release added this to the v1.18.0 milestone Jun 22, 2021
@calmh calmh added the frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion label Aug 11, 2022
@syncthing syncthing locked and limited conversation to collaborators Aug 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants