Commit Graph
97 Commits
Author SHA1 Message Date
Kenneth Skovhede 230d80642a Fixed invariant formatting helpers
This fixes an issue with formatting for invariant values that was caused by incrorrect function overload selection.

To avoid future issues, the two similar functions have been renamed to clarify what they are working for.
2025-09-25 11:14:54 +02:00
Carl Johnsen 7670ea9a58 Ensured that all values that are passed to interpolation strings have been passed through FormatInvariant to prevent SQLite errors related to string formatting cultures. 2025-09-05 14:11:05 +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
Kenneth Skovhede e17759efe3 Fixed some quotes and a TODO 2025-08-05 13:47:57 +02:00
Carl Johnsen 6460e33787 Added missing double quotes to the SQL queries in LocalRepairDatabase.FixEmptyMetadatasets() 2025-06-19 13:23:39 +02:00
Carl Johnsen f6ac30e831 Merge remote-tracking branch 'upstream/master' into performance/mssqlite-async 2025-06-19 12:17:30 +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 04c52010fe Made the LocalRepairDatabase methods accept a cancellation token 2025-06-19 07:26:54 +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 f221098c28 Formatted SQL queries - mainly adding double quotes where they were missing. 2025-06-18 10:42:08 +02:00
Carl Johnsen ae633fe0e8 Added more docstrings 2025-06-18 07:42:57 +02:00
Kenneth Skovhede 2c5c01160c Added a check and repair for empty metadata
This PR adds a check for empty metadatasets (length = 0) and replaces such sets with a default metadataset.

This fixes #6350
2025-06-16 16:35:07 +02:00
Carl Johnsen 3d11a05400 Added .ConfigureAwait(false) to all of the await statements 2025-06-12 08:34:29 +02:00
Carl Johnsen cb06275a81 Removed TODOs 2025-06-11 11:30:13 +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 bd493638af Merge branch 'master' into performance/mssqlite-async 2025-06-02 10:39:33 +02:00
Kenneth Skovhede 3ebc50a89d Adding repair for index files
Since index files only contains information related to recreating the database, they can be recreated directly from a working database.

This PR adds an automatic repair feature that replaces index files if they are missing content. This will gradually repair remote index files if they are affected by the compact bug that re-wrote index files without the blocklists.

To fully repair, it is possible to run the `Test` command with the option `--full-remote-verification=indexonly` and a large number of samples. Since the new option `--replace-faulty-index-files` is default set to `true` this will repair any defective index files and ignore all others.

This update uncovered that the Test method would previously not verify the presence of blocklists in the index files. This is likely a very old bug, caused by the fact that the original implementation did not place blocklisthashes in the index files. The omission of this check is the reason the extent of the compact issue was not discovered earlier.

With this PR it is now also visible that there is ample room for error in creating the index files during the backup process. This is caused by the parallel processing and carry-over, where the index files are created on-the-go, so they are ready to upload once the blocks are filled.

While this is likely good for performance, it has some drawbacks.
- A failed block upload will cause a rewrite of the index file
- An elaborate callback system is needed to update the index file
- It is possible to race against the database and create extra blocklist hashes, bloating the index files (causes problems on verification)

A subsequent task is to rewrite the logic to not touch the index files outside the backend manager, so the backend manager will just use the database to create the index file. This means the same code will be invoked for both the create, the recreate, and the replacement.

For now, extra content in index files is logged with the verbose log level.

This fixes #6296
2025-05-27 17:15:02 +02:00
Carl Johnsen 9419f225c0 Creating a new LocalRepairDatabase should close the database 2025-05-23 11:17:30 +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 e643c2dfce Method signature changed 2025-05-22 08:26:43 +02:00
Carl Johnsen d45e977d53 Found more factory construction inconsistencies 2025-05-21 08:47:24 +02:00
Carl Johnsen 3e3a9b5aa9 More SQL query restructuring 2025-05-20 06:07:45 +02:00
Carl Johnsen ab6b2a64c9 Added the extension method to pass ReusableTransactions directly on SqliteCommands 2025-05-19 10:37:37 +02:00
Carl Johnsen ba5f9e8a3d Restructured SQL statements in LocalRepairDatabase as well as changing calls to SqliteCommands to use a chain of method calls rather than a sequence of statements 2025-05-19 10:37:13 +02:00
Carl Johnsen 8bc81a45db Changed LocalRepairDatabase to use factory for construction 2025-05-19 07:09:12 +02:00
Carl Johnsen 3eeeaf350b Simplified using statements where applicable 2025-05-16 12:21:56 +02:00
Carl Johnsen a2757281be Updated LocalRepairDatabase to async using Microsoft.Data.Sqlite 2025-05-16 12:21:56 +02:00
Kenneth Skovhede 0c3d74c580 Removed unused code 2025-05-14 20:40:25 +02:00
Kenneth Skovhede 33a21c782d Fixed incorrect transaction use 2025-05-10 09:55:13 +02:00
Kenneth Skovhede 91cfdebd95 Fixed issue with repair leaving old filesets in the database.
Fixed issue with the full/partial state not being replicated for re-created filesets
2025-05-10 09:12:11 +02:00
Kenneth Skovhede fe866ceb9f Implemented support for repairing the database when only parts of the source data is available.
This repair will leave the database in a still-broken state, but if this is run prior to purge-broken-files, less data will be lost.

Also updated the purge-broken-files operation to keep files and directories in the set, if they are only missing metadata.
2025-05-09 11:12:29 +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 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 0b735d79ff More cleanup and a few bug fixes 2025-04-03 16:38:51 +02:00
Kenneth Skovhede 2006556778 Fixed some more nullable support in the database layer 2025-04-03 15:46:20 +02:00
Kenneth Skovhede 6db50381cb Additional fixes 2025-04-03 13:58:06 +02:00
Kenneth Skovhede 424cc6f3ad Added LocalRepairDatabase 2025-04-02 23:34:30 +02:00
Kenneth SkovhedeandGitHub 85f5ddde1d Merge branch 'master' into feature/guard-against-missing-files 2025-03-25 11:39:13 +01:00
Kenneth Skovhede 3c741cbcfc Delete empty index files
If there are index files with no references, they will now be deleted by the repair process.

Such files are likely leftovers from an earlier version that would leave such files if various errors happened.
2025-03-20 22:21:57 +01:00
Kenneth Skovhede d40301b2b7 Guard against fileset errors
This PR adds a few extra consistency checks to the database, so any failure in the operations is detected earlier than before.

Especially when cleaning temporary and partial files, it is important that the deletes do not remove unexpected entries.

Also, after a recreate, repair or purge command, the database consistency is verified, so it becomes easier to identify which operation caused the failure.

To assist in trouble shooting, there is also a more elaborate error message if a fileset discrepancy is detected, that pinpoints which versions are affected.

Finally, the repair command has been extended to support recreating a fileset from the remote data.
2025-03-20 15:59:14 +01:00
Kenneth Skovhede 833a77bcf6 Fixed a transition issue 2025-03-19 17:21:16 +01:00
Kenneth Skovhede bb1aa8e1f7 Cosmetic cleanup
Removed superfluous namespaces.
Using `var` most places.
Using extension methods for common setup of commands.
2025-03-14 14:34:56 +01:00
Kenneth Skovhede 7234d43961 Fixed all SQL strings to use interpolation and forced them into the FormattableString handler using the invariant formatting. 2025-03-14 12:13:17 +01:00
Kenneth Skovhede f342d70819 Implemented forced invariant locale on all SQL strings.
This fixes #6023
2025-03-13 23:06:32 +01:00
Kenneth Skovhede 55fc5d2e6c Added support for recreating filesets and remote lists in some scenarios 2025-03-10 14:41:12 +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 Skovhede 473c6cbbb8 Merge commit '4f577c65a4d8806f79637c50c21ca3a683c5a07a' into feature/kestrel-avalonia-upgrade 2024-03-04 12:21:53 +01:00
Kenneth Skovhede 40dd3c6816 Updated all license mentions to MIT 2024-02-28 15:45:30 +01:00
Thomas Suckow ecb0249259 dotnet no longer provides a method for a string to hashalgorithm
* Also fix up not diposing of hashers
2021-04-04 11:17:13 -07:00