Skip to content

all: Transactionalize db.FileSet (fixes #5952) - #6239

Merged
calmh merged 7 commits into
syncthing:masterfrom
imsodin:db/trans
Jan 21, 2020
Merged

calmh merged 7 commits into
syncthing:masterfrom
imsodin:db/trans

Conversation

@imsodin

@imsodin imsodin commented Dec 27, 2019

Copy link
Copy Markdown
Member

When pulling we go once over all needed files in the db, and then at various later points do lookups in the db. In the meantime changes may happen (e.g. that's the only explanation I have for #5952). This PR moves db access through db.FileSet to db.Snapshot which can be obtained from db.FileSet.
The huge diff on lowlevel.go and transaction.go is just copying over the methods that created a transaction at the beginning to actually be methods on transactions themselves.

Maybe it would be worth keeping utility functions on db.FileSet that allow access without taking a snapshot. I would definitely make especially some testing code shorter, then again I think it has some merit being force to think about snapshots (potential concurrent db changes) when dealing with the db.

Comment thread lib/db/set_test.go
if f, ok := s.Get(protocol.LocalDeviceID, file); !ok {
snap := s.Snapshot()
defer snap.Release()
if f, ok := snap.Get(protocol.LocalDeviceID, file); !ok {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

ifElseChain: rewrite if-else to switch statement (from gocritic)

Comment thread lib/db/transactions.go Resolved
Comment thread lib/model/folder_sendrecv.go Resolved
Comment thread lib/model/folder_sendrecv.go Resolved
Comment thread lib/model/testutils_test.go Resolved
@imsodin imsodin changed the title lib/db, lib/model: Transactionalize db.FileSet (fixes #5952) all: Transactionalize db.FileSet (fixes #5952) Jan 3, 2020
@calmh

calmh commented Jan 11, 2020

Copy link
Copy Markdown
Member

This sounds like a good change and I’m not ignoring it; I’ve been traveling with limited internet but I’m back in business for real on Monday.

calmh
calmh previously approved these changes Jan 21, 2020
* master:
  lib/model: Handle progress emitter zero interval (fixes syncthing#6281) (syncthing#6282)
  build(deps): bump github.com/pkg/errors from 0.9.0 to 0.9.1 (syncthing#6279)
  cmd/syncthing: Always use monitor process (fixes syncthing#4774, fixes syncthing#5786) (syncthing#6278)
  lib/syncthing: Wait for actual termination on Stop() (syncthing#6277)
  lib/model: Remove legacy handling of symlinks (syncthing#6276)
  lib/model: Return paused summary instead of error on paused folders (syncthing#6272)
  lib/config: Add some info to the folder marker missing (ref syncthing#5207) (syncthing#6270)
@calmh
calmh merged commit 08f0e12 into syncthing:master Jan 21, 2020
@imsodin
imsodin deleted the db/trans branch January 21, 2020 17:28
calmh added a commit to calmh/syncthing that referenced this pull request Jan 21, 2020
* master:
  all: Transactionalize db.FileSet (fixes syncthing#5952) (syncthing#6239)
@calmh calmh added this to the v1.4.0 milestone Jan 24, 2020
calmh added a commit to calmh/syncthing that referenced this pull request Jan 30, 2020
* master: (28 commits)
  gui, man, authors: Update docs, translations, and contributors
  lib/config, lib/model: Limit concurrent pulls (fixes syncthing#5914) (syncthing#6290)
  lib/db: Fixup last commit with better key name
  lib/db: Configurable block GC time (syncthing#6295)
  lib/db: Deduplicate block lists in database (fixes syncthing#5898) (syncthing#6283)
  lib/relays: Fix incorrect timeout, bring back logging (ref syncthing#6289) (syncthing#6291)
  gui, man, authors: Update docs, translations, and contributors
  all: Transactionalize db.FileSet (fixes syncthing#5952) (syncthing#6239)
  lib/model: Handle progress emitter zero interval (fixes syncthing#6281) (syncthing#6282)
  build(deps): bump github.com/pkg/errors from 0.9.0 to 0.9.1 (syncthing#6279)
  cmd/syncthing: Always use monitor process (fixes syncthing#4774, fixes syncthing#5786) (syncthing#6278)
  lib/syncthing: Wait for actual termination on Stop() (syncthing#6277)
  lib/model: Remove legacy handling of symlinks (syncthing#6276)
  lib/model: Return paused summary instead of error on paused folders (syncthing#6272)
  lib/config: Add some info to the folder marker missing (ref syncthing#5207) (syncthing#6270)
  assets, gui: Losslessly compress all JPG, PNG, and PDF images (syncthing#6265)
  cmd/strelaypoolsrv: Serve gzip compressed responses
  gui, man, authors: Update docs, translations, and contributors
  gui, man, authors: Update docs, translations, and contributors
  build: go mod tidy
  ...
calmh added a commit to calmh/syncthing that referenced this pull request Jan 30, 2020
* master: (32 commits)
  gui, man, authors: Update docs, translations, and contributors
  lib/config, lib/model: Limit concurrent pulls (fixes syncthing#5914) (syncthing#6290)
  lib/db: Fixup last commit with better key name
  lib/db: Configurable block GC time (syncthing#6295)
  lib/db: Deduplicate block lists in database (fixes syncthing#5898) (syncthing#6283)
  lib/relays: Fix incorrect timeout, bring back logging (ref syncthing#6289) (syncthing#6291)
  gui, man, authors: Update docs, translations, and contributors
  all: Transactionalize db.FileSet (fixes syncthing#5952) (syncthing#6239)
  lib/model: Handle progress emitter zero interval (fixes syncthing#6281) (syncthing#6282)
  build(deps): bump github.com/pkg/errors from 0.9.0 to 0.9.1 (syncthing#6279)
  cmd/syncthing: Always use monitor process (fixes syncthing#4774, fixes syncthing#5786) (syncthing#6278)
  lib/syncthing: Wait for actual termination on Stop() (syncthing#6277)
  lib/model: Remove legacy handling of symlinks (syncthing#6276)
  lib/model: Return paused summary instead of error on paused folders (syncthing#6272)
  lib/config: Add some info to the folder marker missing (ref syncthing#5207) (syncthing#6270)
  assets, gui: Losslessly compress all JPG, PNG, and PDF images (syncthing#6265)
  cmd/strelaypoolsrv: Serve gzip compressed responses
  gui, man, authors: Update docs, translations, and contributors
  gui, man, authors: Update docs, translations, and contributors
  build: go mod tidy
  ...
imsodin added a commit to imsodin/syncthing that referenced this pull request Feb 11, 2020
@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 Jan 21, 2021
@syncthing syncthing locked and limited conversation to collaborators Jan 21, 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.

4 participants