Commit Graph
80 Commits
Author SHA1 Message Date
Carl Johnsen 6ee76a29d3 Made the callback on a put command to the backend be a function returning an awaitable Task rather than an Action. 2025-06-23 10:27:09 +02:00
Carl Johnsen 2412800c0c Removed the sqlite page cache option. It should be set through the environment variable, or some other way of providing a custom database configurotion 2025-06-19 11:41:39 +02:00
Carl Johnsen 32efa4b845 Updated all of the handler calls to database methods to forward their cancellation token 2025-06-19 09:47:33 +02:00
Carl Johnsen 9ac583db94 Made all relevant using statements use await to use DisposeAsync 2025-06-18 11:53:11 +02:00
Carl Johnsen 3d11a05400 Added .ConfigureAwait(false) to all of the await statements 2025-06-12 08:34:29 +02:00
Carl Johnsen 8cff30f99b Made BlockVolumeWriter.AddBlock async 2025-06-11 08:17:04 +02:00
Carl Johnsen 4032e8b07a Disposing a database calls PRAGMA optimize, and thus needs a transaction. This means that the database themselves handles disposing and not restarting the final transaction 2025-05-27 07:07:38 +02:00
Carl Johnsen 6c7e67dd28 Post master merge fixes 2025-05-22 14:35:15 +02:00
Carl Johnsen a37f0dda31 Merge branch 'master' into performance/mssqlite-async 2025-05-22 14:09:17 +02:00
Carl Johnsen cdba7ef6e9 Updated Utility to use the new async database methods 2025-05-22 08:25:25 +02:00
Carl Johnsen f4981ec0e4 Updated CompactHandler to use the new async database methods 2025-05-21 15:31:23 +02:00
Carl Johnsen 99dddd4839 Removed whitespace 2025-05-21 15:31:04 +02:00
Kenneth Skovhede 6a188f0d0c Avoid DB queries if the is no work to do 2025-05-17 11:24:57 +02:00
Kenneth Skovhede 80ff71c856 Preserve space during compacts
This update changes the logic for deleting volumes during compacting to delete leftover volumes as soon as a new volume has been uploaded.

This ensures that the compact process will at most require space for one extra volume during the compact step.

This fixes #5919
2025-05-17 10:59:27 +02:00
Kenneth Skovhede d0a666a3e1 More flushing during compact to deal with transaction issues 2025-05-16 10:35:07 +02:00
Kenneth Skovhede 814064d1ed Rewrote the central query that returns the blocklists needed for index volumes 2025-05-16 10:33:54 +02:00
Kenneth Skovhede d22ce5370e Rewrote the repair for scenarios where remote files are missing.
This adds a number of additional features to the repair process so it can actually fully recover if all data is present.

Also added a several tests to ensure that the functionality works in multiple scenarios.

This fixes #5987
2025-05-08 10:31:38 +02:00
Kenneth SkovhedeandGitHub 0c4fffa6ce Merge branch 'master' into feature/add-sqlite-cache-value 2025-04-23 15:25:00 +02:00
Kenneth Skovhede e6ba6098d7 Implemented immediate transaction commits for almost all uploads.
This ensures that files cannot appear on the remote destination, despite terminating the host program.

This fixes #4485

There is still work needed to handle the repair and compact operations so they use transactions and can commit changes during transfer progress.
2025-04-23 12:11:16 +02:00
Kenneth Skovhede 0a7a1cd689 Added option to set the SQLite page cache
This adds an extra option to allow setting the SQLite page cache size as a regular option.

Prior to this commit it was only possible to set the SQLite page cache size via environment variables.

The option to use environment variables is preserved, and as options from the environment variable are applied after the new setting, environment variables take precedence.

The default value for the new option is to use 1% of the system memory for the page cache. For the restore process, a connection per worker may be made which defaults to half the number of cores, so the maximum amount of memory is 1% * half the CPU cores.

This is just the upper limit, and SQLite may choose not to use all of it.

This fixes #6178
2025-04-22 14:26:46 +02:00
Kenneth Skovhede faede65d8d Changed transactions to use a wrapper that ensures a transaction is allocated. 2025-04-14 12:04:00 +02:00
Kenneth Skovhede 8753e5dc85 Merge remote-tracking branch 'origin/master' into feature/improve-compact-block-use-check 2025-04-01 15:54:54 +02:00
Kenneth Skovhede 7f008341df Untangle the results and database
The code was using a two-way reference linking the database to the results and the results to the database.

However, this was not really used so it ended up just cluttering the code. With this commit, the results and databases are no longer keeping track of each other, and the only interaction is when the results are written to the database at the end of the operation.

To ensure result data is always written, this code has been moved into the controller, which will now flush the results for all operations. Prior to this, only some operations would write result data to the log.

The controller now also handles logic for cleaning old log data and invoking the vacuum command.

Fixed a bug due to using System.Text.Json where some attributes from NewtonSoft.Json were being applied and not picked up.
2025-03-20 09:51:49 +01:00
Kenneth Skovhede c1bdaa069e Async operation handlers
Rewrote all operation handlers to be async.
This moves the async/sync threshold out into the controller.

Fixed all the uses of cancellation token in the handlers to use the provided cancellation token.

Introduced a new ReusableTransaction that can be passed around, avoiding a ref parameter passing of the transaction instance.
2025-03-14 10:41:14 +01:00
Kenneth Skovhede 5edfcc5c6a Prevent blocksize near remote volume size
If the user selects the blocksize to be the same as the remote volume size, this will cause each block to be in a separate volume and will trigger repeated compact calls.

This commit adds a check that ensures the volume size is large enough to hold at least two blocks.

Also fixed an issue where the compact could create volumes larger than the set limit (at most one block larger).
2025-03-13 12:09:57 +01:00
Kenneth Skovhede 1de0a92413 Strategy is now to disallow compact/delete/purge if the remote state contains partial data.
Backup will auto-repair, and user otherwise need to call "repair" to recover the state, before invoking compact/delete/purge.
This is done to prevent cases where the remote state contiains partial data and the automatic cleanup process would remove remote files.
2025-03-08 15:28:02 +01:00
Kenneth Skovhede ca236f03e3 Renamed flag to more precisely describe the purpose 2025-03-06 14:56:35 +01:00
Kenneth Skovhede 1321488527 Improve failure detection
This commit adds extra logic to prevent cases where the backup reports success but leaves behind partial files.

A new flag is recorded to track if partial files are possible. If no partial files are possible, the verification will fail if any are found.
2025-03-06 12:02:11 +01:00
Kenneth Skovhede 7031bc57b6 Adding ConfigureAwait(false) to all async enumerations 2025-02-18 09:18:36 +01:00
Kenneth SkovhedeandGitHub d99f74ed94 Rewrite the backend manager. (#5896)
* Rewrite the backend manager.

This creates a new more logic backend manager that handles all backend operations.

For each top-level operation, there is now a single backend manager instance that is passed to sub-commands.

The internals of the backend manager are now rewritten to use async logic instead of threading.

The design uses a single task runner that dispatches operations and honors concurrent settings and limits from one place.

The logic for each operation has been moved into a separate files/classes to make it easier to understand each operation.

This fixes #5804

* Fixed a few issues with not awaiting tasks

* Fixed not creating empty databases

* Fixed an issue with hashes not being recorded on download

* Reworked the download logic to avoid attempting to decrypt the file if it has been modified.

* Review fixes

* Renamed db collector to better reflect the purpose.

* Review fixes
2025-01-28 08:54:50 +01:00
Kenneth SkovhedeandGitHub 9464caf622 Feature/update license 2025 (#5851)
* Fixed some minor whitespace issues

* Updated all copyright to 2025
2025-01-07 09:40:39 +01:00
Kenneth SkovhedeandGitHub ff1b2b7990 Simplified task control (#5753)
* Simplified task control by having all logic in a single class and using async control mechanism
* Fixed the tests
* Made the marking of a backup partial explicitly communicated if the enumeration process is stopped.
* Added support for pausing active transfers
* Introduced transfer token to abort operations.
* Updated the way LiveControl is emitting events.
* Retains the paused state of the server across reboots, this fixes #5760.
* Reworked the way throttle speeds are propagated through LiveControls.
* Added option to pause transfers in the UI.
* Removed throttle settings from the LiveControls class so it is exclusively handled by the ApplicationSettings.
* Removed `thread-priority` as it does not work at all when tasks are used.
* Fixed the stop dialog and API to only support stop and abort.
* Removed unused variables
2024-12-18 08:27:59 +01:00
Kenneth Skovhede 07843c6c2d This adds additional checks to the check if a block is in use, by checking if it is in use by the volume that we are examining.
This is taken from #4982
2024-11-01 16:45:25 +01:00
Kenneth Skovhede db517a300b Implemented a fix for compaction issues that could cause inconsistent views of the remote storage. 2024-11-01 14:50:26 +01:00
Carl Johnsen 20aea95007 Fixed inconsistent variable naming 2024-10-21 17:50:18 +02:00
Carl Johnsen ce64b7e549 Sped up preliminary work in DoCompact.
The first optimization was to add guards around the queries in case the second collection is empty (which is was when the slow path was found).
The second optimization is to use a HashSet for the second collection, as this speeds up lookup, compared to using two List of string.
2024-10-21 14:27:18 +02:00
Kenneth Skovhede c890e824ee Implemented test for reproducing issue #5196
Fixed issue by changing order options are written and verified.
Some whitespace changes due to renaming a method
2024-05-21 15:48:29 +02:00
Kenneth Skovhede 40dd3c6816 Updated all license mentions to MIT 2024-02-28 15:45:30 +01:00
Janandgpatel-fr b894a197a9 Fix missing file error caused by interrupted compact.
Before the dindex files are deleted on the remote, update the state in the database to Deleting. Previously, only dblock files were handled this way.
Patch by warwickmm
Closes #4129
2023-09-21 22:56:52 +02:00
Kenneth Hsu b53770b589 Add VerifyRemoteList overload to reduce duplicated code. 2020-04-05 11:46:08 -07:00
Sean Templeton d5e064ae45 Fix a few more issues with stop now
When a backup is interrupted it will now show as a partial backup in the list of backups on the restore files page.

Temporary filelist volumes are protected from deletion in several places. All but the RestoreHandler
only protect the most recent filelist. The RestoreHandler protects all temporary filelist volumes as the user
might be restoring from one that would be deleted.

Prevent the CoCoL BackendRequests channel is retired exception from appearing when the backup is stopped by checking
if the channel is retired before trying to add the FlushRequest to the channel. Any exceptions from the BackendUploader
task will still be thrown.
2020-03-01 21:19:07 -06:00
Sean Templeton 04662bace1 Write blocklists when compacting files
The list folder was not being written to dindex files when performing a
compact operation. After the data blocks have been moved to a new volume
and the new volume data is finished being written to the new index file,
read the blocklists from the database and write them to the new index
file.
2020-01-19 21:57:08 -06:00
Kenneth Hsu 2aa76881a5 Mark fields that don't need to be reassigned as readonly.
This makes it explicit at compile-time that these fields should not be
reassigned outside the constructor.
2019-10-19 13:59:22 -07:00
drwtsn32x cfeabfb2dd Add auto vacuum interval option 2019-07-29 17:56:43 -07:00
Kenneth Hsu 457254d9e1 Remove unused local variables. 2019-04-17 20:10:53 -07:00
Kenneth Hsu e82c11b39b Avoid possible null reference exception. 2019-02-16 20:43:05 -08:00
Kenneth Hsu 3fc9276cdd Remove temp files when compact operation is not performed.
This concerns issue #3652.
2019-02-16 19:53:06 -08:00
Kenneth Hsu d72128ec83 Remove unused method parameters. 2018-10-06 15:09:43 -07:00
Kenneth Hsu 9c6bccf478 Use braces to improve readability.
Previously, the indentation of the following code block gave the
impression that it was part of the foreach loop when in fact it would
only be executed once.
2018-05-13 14:24:13 -07:00
Kenneth Skovhede 842fd96543 Implemented a new logging system that is more transparent and allows a more granular way of picking log messages.
Added ID's to each log message and each exception to allow later introduction of a Knowledgebase service that explains each error in more detail.
2018-03-15 09:12:34 +01:00