borg icon indicating copy to clipboard operation
borg copied to clipboard

use borgstore and other big changes

Open ThomasWaldmann opened this issue 1 year ago • 15 comments

Fixes #7377.Fixes #7379. Fixes #4428.

Fixes #1293 (in a different way).

Fixes #916, fixes #474 (no LocalCache any more).

Fixes #3128 (gone). Fixes #2681. Fixes #2571. Fixes #2454.

Fixes #6567 (not needed any more).

Maybe builds the foundation to solve #102 (without FUSE) and #1070.

new repository based on borgstore project

stores chunks into separate files (not: segment/pack files, at least for now).

borgstore has a very simple api that makes implementing backends easy.

in borg 2.0, this will primarily use the "file:" backend from borgstore to implement file: and ssh: repositories, but long term we might go away from the borg.remote code (RPC api via ssh) and just use a "remote" borgstore.

there is also a sftp: repository now implemented via the respective borgstore backend. more might be coming, even cloud stuff should be easily possible with that (PRs welcome!).

repository: convergence rather than transactions

borg 1.x used the segment files in a log-like way (only appending new stuff at the end) and implemented transactions via a COMMIT tag - if the transaction was not completed (no COMMIT at the end), it rolled back the incomplete transaction to the last commit.

the code implementing transactions was rather complex and required an exclusive lock on the repo for correct operations.

borg2 now just adds repo objects in the right order, first pushing referenced objects, then the references to them. even if an operation is interrupted, nothing bad happens. there might be some unreferenced objects for a while, but they will get referenced if the operation is retried later and completes. borg compact will deal with anything not needed.

no checkpoint archives, no .borg_part files anymore

saving them was only needed due to the transactional/rollback behavior of borg1.

borg2 does not do that rollback any more, so the checkpoints are not needed. the user can just re-run the interrupted command and it will notice that some stuff is already present in the repo and only transfer new stuff.

new borg compact doing garbage collection

borg compact is still needed to free space in the repo, but it doesn't really need to "compact segments" as there are no segment files anymore. so it will do less I/O to move stuff around in the repo.

but maybe some sort of segment/pack files will come back later, so we'll just keep the command name.

borg compact is now doing more work that was previously done by borg delete and borg check: it determines which chunks are not used anymore (and removes them).

super fast borg delete and borg prune

as borg does not do precise refcounting any more, delete now just kills the archive from the manifest (removing the reference to its root) and lets borg compact clean up all the now unreferenced chunks.

new borgstore-based locking code

repository locking code with lock auto-expiry if lock does not get refreshed regularly by a running borg process. Uses locks/*.

new repo config / repo key storage

Config is now stored into separate files config/* - less risk (e.g. for the repokey) if other config items need updating.

Repokey now stored into keys/* (only 1 key for now).

new manifest storage

the manifest chunk that also had the list of archives inside was split into config/manifest and separate files archives/*.

this is preparing for less locking and more parallelism later.

some features might come back later (stats, quota, append-only, ...)

ThomasWaldmann avatar Aug 14 '24 14:08 ThomasWaldmann

@Ducasse

Before applying extract setup

testLocationAndDate

|temp office|

temp := Counter new count: 3.
office := TemperatureConverter new location: 'Office'

"perform two measures that are logged""We logged the correct temperature"
office measureCelsius: 19.
office measureCelsius: 21.
self
	assert: office temperatures
	equals: { 19. 21 } asOrderedCollection

After applying extract setup

setUp

super setUp.
temp := Counter new count: 3.
office := TemperatureConverter new location: 'Office'

testLocationAndDate

"perform two measures that are logged""We logged the correct temperature"
office measureCelsius: 19.
office measureCelsius: 21.
self
	assert: office temperatures
	equals: { 19. 21 } asOrderedCollection
	

Problem

I think there is a problem one should not use extractSetup on the temporary variables because they are not instance variables which are defined in the global context (setUp method won't even know what they are, and will declare them undeclared variable)

Suggestions

  1. Prompt the user that one of the line includes a temporary variable which can't be extracted in a setUp.

Sahityaaryan avatar Mar 25 '25 23:03 Sahityaaryan