Skip to content

lib/db: Prevent IndexID creation race - #7211

Merged
calmh merged 1 commit into
syncthing:mainfrom
imsodin:lib/preventIndexIDRace
Dec 21, 2020
Merged

calmh merged 1 commit into
syncthing:mainfrom
imsodin:lib/preventIndexIDRace

Conversation

@imsodin

@imsodin imsodin commented Dec 18, 2020

Copy link
Copy Markdown
Member

Purpose

When anyone calls FileSet.IndexID and the local one is zero, we create a new one. Thus two goroutines calling it concurrently may return two different IDs, and the later one will be persisted. I realised this because of logs connected to https://forum.syncthing.net/t/mismatching-index-id-for-us-on-almost-every-restart-again/16036/8:

129:[RTF25] 14:24:38 INFO: Device DWJVRMJ-... folder "A" (a) has mismatching index ID for us (0xA0175C8807ED7CBB != 0x42C01C3C03087F58)
[...]
566:[RTF25] 15:10:32 INFO: Device DWJVRMJ-... folder "A" (a) has mismatching index ID for us (0x42C01C3C03087F58 != 0x6F4E1206A392035F)

However it still seems quite improbable: The race would be between any incoming and any outgoing CC (both call IndexID). Then again, there's quite a few devices and folders in that log, so why not.

Testing

New unit test of questionable style. Before this PR it consistently failed the first time for me, so it does work at least.

@calmh
calmh merged commit 4a78798 into syncthing:main Dec 21, 2020
@imsodin
imsodin deleted the lib/preventIndexIDRace branch December 21, 2020 10:44
calmh added a commit to calmh/syncthing that referenced this pull request Dec 21, 2020
* main: (27 commits)
  lib/fs: Correct wrapping order for meaningful log-caller (syncthing#7209)
  all: Handle errors opening db/creating file-set (ref syncthing#5907) (syncthing#7150)
  cmd/relaypoolsrv: Allow validation of relay join requests by certificate (fixes syncthing#7196) (syncthing#7217)
  lib: Close underlying conn in protocol (fixes syncthing#7165) (syncthing#7212)
  lib/db: Prevent IndexID creation race (syncthing#7211)
  gui: Reflect change in untrusted in sharing tab (syncthing#7201)
  lib/db: Remove index ids when dropping folder (syncthing#7200)
  lib/model: Fix flaky test and add some scanning debug (syncthing#7214)
  lib: Consistently set suture logging (syncthing#7202)
  lib/model: Unflake TestIgnoreDeleteUnignore (syncthing#7208)
  gui: Apply changes to untrusted (ref syncthing#6443) (syncthing#7206)
  lib/config: Remove deprecated pending entries from config (ref syncthing#6443) (syncthing#7204)
  all: Store pending devices and folders in database (fixes syncthing#7178) (syncthing#6443)
  gui, man, authors: Update docs, translations, and contributors
  gui: Sort folders and devices in advanced config modal (syncthing#7192)
  model: Actually print folder description in "Overriding" log message
  gui: version.tags is an array, which is truthy when empty
  build: Switch to gopsutil's v3 module (syncthing#7191)
  build: Update notify (fixes syncthing#7076) (syncthing#7189)
  lib/api: Returns tags in version as list (syncthing#7190)
  ...
@calmh calmh added this to the v1.13.0 milestone Dec 21, 2020
hiqua pushed a commit to hiqua/syncthing that referenced this pull request Jan 11, 2021
@st-review st-review added the frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion label Dec 22, 2021
@syncthing syncthing locked and limited conversation to collaborators Dec 22, 2021
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