Commit Graph
194 Commits
Author SHA1 Message Date
Kenneth Skovhede 179d1ceb47 Make controller Async
This PR has a large blast radius because it takes the final step and bumps up the Controller to be fully async.

We have historically done a piece-by-piece update, so all operations were already async but the controller interface was kept synchronous.

With this update, the controller is now fully async and all tests are updated.

Most places where the new C# compiler warns about function names not ending in `Async` were also adressed, giving a massive refactor change.

Functionally, no changes are done.
2026-05-13 15:04:13 +02:00
Kenneth Skovhede 89654c2474 Add safeguard to synthetic filelist
This adds an extra clause when building a synthetic filelist to avoid cases where the synthetic filelist fails to be generated because some entries are orphans.

The tests that reproduce this are quite slow and require some tampering with the database to get into the faulty state, so the tests will not run in CI testing but can manually be executed.
2026-05-12 13:00:02 +02:00
Kenneth Skovhede 308e8428c7 Add slow query monitor
When queries are slow on end-user machines it is hard to debug what the exact problem is.

The typical flow is to discover a "stuck" process. But since profiling logging was not enabled there is no output.

The user then has to re-run the problematic operation with profiling on, and locate the last output where the call gets stuck.

This PR introducces a monitor mechanism where all queries register themselves prior to execution, and then de-register once done.

At a fixed interval, the list of active queries is examined, and if a query is found to be running longer than the threshold, it will be logged as a warning.

This means the user can simply go view the live log for warnings, and the offending query will be emitted.

The default threshold is set at a conservative 30 minutes. Since the timer only checks at the interval, it can take at most 2x the interval before a message is logged. After this, a message is logged each time the interval is reached (e.g., a new warning is logged every 30 min).

The option `--long-database-query-threshold` can be used to set a different threshold.
2026-05-08 10:30:47 +02:00
Kenneth Skovhede 584884de0a Always log the append queries as they are not in the hot-path for backups 2026-05-06 15:20:16 +02:00
Kenneth Skovhede ab487bdde2 Optimize synthetic filelist creation
This PR adds a test that generates a synthentic filelist of a variable size, and then measures the time it takes to recreate the fileset.

As there was a reported slowdown, analysis indicated that the query would grow in the order of O=N^2, where N is the number of paths.

The code is then updated to instead use some temporary on-disk space to lay out the paths and then insert them as a new fileset. This should bring the time down to O=N.

Based on a test with 10k files, the query speed up is ~900x, but will be more on larger filesets.
2026-05-06 15:16:10 +02:00
Kenneth Skovhede 4244e71fee Improve SQL logging
This PR improves SQL logging by capturing many places where the calls would previously just hit the database and not produce any logging output.
2026-05-06 10:52:58 +02:00
Kenneth Skovhede c0f40e19ca Updated copyright year to 2026 across the project 2026-04-16 15:21:24 +02:00
Kenneth Skovhede e7aa60fba0 Handle duplicate source paths
This PR adds guards to prevent creating filesets with multiple files that have the same path.

While it should technically be impossible to have multiple entries that have the same path, it could happend either due to glitches or because the source data (manual lists, remote sources, etc) returns duplicates.

This PR adds a simple check for each folder to ensure that on a folder-level, duplicate paths cannot be introduced.

There is also a post-backup check to evict any duplicates, and the recreate process will reject duplicate paths.

Finally, the repair command will remove duplicates if they somehow manage to get into the database anyway.

A database-level prevention is not currently feasible as it needs a cross-table check for uniqueness, which requires more work from the database to check for each added file. Since this is expected to be a very rare event, the added processing was not justified.
2026-02-05 11:06:41 +01:00
Kenneth SkovhedeandGitHub 1b1719e924 Merge pull request #6718 from duplicati/feature/add-office-365-backup
Add office 365 backup and restore
2026-02-01 13:12:44 +01:00
Kenneth Skovhede ebbc564424 Added fix for manual changelist
This PR updates the logic for using `--changed-files` so the combined fileset no longer has additional (left-over) entries.

This fixes #6529
2026-01-30 17:33:32 +01:00
Kenneth Skovhede 1523f730e3 Added support for storing metadata in the database 2026-01-14 10:01:20 +01:00
Carl Johnsen 1a5fef36d7 Removed whitespace 2025-09-05 14:07:58 +02:00
Carl Johnsen b3fe276a13 Ensured that all temporary tables uset the same type of generated guid name 2025-09-05 14:06:55 +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 7e979a4e9b Found some methods in LocalBackupDatabase that didn't accept a cancellation token 2025-06-19 11:01:12 +02:00
Carl Johnsen 8039cbb0f6 Made the LocalBackupDatabase methods accept a cancellation token 2025-06-18 16:00:20 +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 859b65054d Simplified using statements that uses databases or accesses their methods 2025-06-18 11:52:05 +02:00
Carl Johnsen f221098c28 Formatted SQL queries - mainly adding double quotes where they were missing. 2025-06-18 10:42:08 +02:00
Carl Johnsen 8814fdebcc Added more docstrings 2025-06-17 15:13:33 +02:00
Carl Johnsen 1f97832546 Classes implementing DisposeAsync should also implement the interface 2025-06-17 15:11:25 +02:00
Carl Johnsen 1ece8398b6 Reordered tuple to match name 2025-06-17 14:02:18 +02:00
Carl Johnsen e81100de04 Started on adding docstrings 2025-06-17 09:59:22 +02:00
Carl Johnsen 3d11a05400 Added .ConfigureAwait(false) to all of the await statements 2025-06-12 08:34:29 +02:00
Carl Johnsen e5337e4d26 Formatted SQL queries 2025-06-11 12:09:58 +02:00
Carl Johnsen f373880c5a Renamed ExpandInClauseParameterAsync, as one of them isn't actually async.
Postfix mssqlite has been added as well to not clash with the IDb implementation
2025-06-11 10:47:40 +02:00
Carl Johnsen 9c2252f36c Ensured common order and interface for the async extension methods. 2025-06-11 10:46:04 +02:00
Carl Johnsen 087ff65646 Removed synchronous helper method 2025-06-11 07:41:03 +02:00
Carl Johnsen ff2e8ddd68 Found an SQL query missing the transaction 2025-05-28 05:53:44 +02:00
Carl Johnsen c4d550572a Added missing quotes around table name containing a dash (-), which led to a syntax error 2025-05-28 05:53:14 +02:00
Carl Johnsen e11d6377ac Construction chain was incorrect for LocalBackupDatabase 2025-05-26 09:06:42 +02:00
Carl Johnsen 5408570643 All SQL queries should be performed inside of a transaction 2025-05-26 09:03:21 +02:00
Carl Johnsen abc7c79841 Dispose made infinite recursion between different class derivations 2025-05-23 08:20:00 +02:00
Carl Johnsen dc4404e751 Added missing await 2025-05-22 15:28:35 +02:00
Carl Johnsen 22550be73c SQLite parameters are case sensitive. 2025-05-22 13:34:29 +02:00
Carl Johnsen 2cd1692532 Temporary fix to distinguish between new and legacy extension method 2025-05-22 13:25:42 +02:00
Carl Johnsen d11b4e58e7 Reworked the factory construction chains to forward an instantiated object where applicable 2025-05-21 07:24:36 +02:00
Carl Johnsen 3e3a9b5aa9 More SQL query restructuring 2025-05-20 06:07:45 +02:00
Carl Johnsen 0b508d2575 Started work on restructuring the SQL queries in LocalBackupDatabase. 2025-05-19 21:59:44 +02:00
Carl Johnsen d73a555647 Restructured the SQL queries in LocalBackupDatabase and made sure it's properly async 2025-05-19 15:43:55 +02:00
Carl Johnsen 48e6b61977 Purged IDb from LocalBackupDatabase 2025-05-19 14:40:00 +02:00
Carl Johnsen 4ab7f290a7 Updated LocalBackupDatabase to use factory construction 2025-05-19 13:19:24 +02:00
Kenneth SkovhedeandGitHub 171eb1bb12 Merge branch 'master' into feature/add-sqlite-cache-value 2025-04-23 16:34:55 +02:00
Kenneth Skovhede 3ff868b0f9 Removed tracking of files sizes, and implemented it with a database lookup 2025-04-23 15:39:32 +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 1095850965 Reworked the way deleted blocks are detected.
This should have a much lower performance impact.
2025-04-06 08:41:59 +02:00
Kenneth Skovhede cfad020ef2 Merge commit '61892a40d9aff663da86eda273505970268f6384' into feature/improve-block-reuse 2025-04-06 08:36:24 +02:00
Kenneth Skovhede 8b72528030 Re-implemented the change statistics calculation. 2025-04-05 21:42:05 +02:00
Kenneth Skovhede bb24036602 Fixed performance degradation after parameter queries 2025-04-05 09:25:10 +02:00
Kenneth Skovhede 0b735d79ff More cleanup and a few bug fixes 2025-04-03 16:38:51 +02:00