Commit Graph
62 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
Carl Johnsen 4f65127ed7 Removed throwing the exception, since recreating the database will restore the hash 2025-08-06 10:16:11 +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 4f7760f092 Made the LocalTestDatabase methods accep a cancellation token 2025-06-19 08:04: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 ae633fe0e8 Added more docstrings 2025-06-18 07:42:57 +02:00
Carl Johnsen 224e883e8d Formatted SQL query strings 2025-06-18 07:30:39 +02:00
Carl Johnsen 20716e3fa6 Made some more of the internal classes in LocalTestDatabase implement IAsyncDisposable 2025-06-18 07:25:24 +02:00
Carl Johnsen eb4f763831 LocalTestDatabase.Basiclist now implements IAsyncDisposable 2025-06-18 06:59:57 +02:00
Carl Johnsen 3d11a05400 Added .ConfigureAwait(false) to all of the await statements 2025-06-12 08:34:29 +02:00
Carl Johnsen fd5823a2f4 Found unformatted SQL queries in LocalTestDatabase 2025-06-11 10:54:02 +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 caa3c13dbe Post master merge fixes 2025-06-02 11:50:35 +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 5ffff0e32e Fixed a method being synchronous in LocalTestDatabase 2025-05-21 14:51:47 +02:00
Carl Johnsen e4cffd5735 Restructured SQL queries in LocalTestDatabase 2025-05-21 09:40:32 +02:00
Carl Johnsen ef2f856c61 Made everything in LocalTestDatabase async 2025-05-21 09:22:29 +02:00
Carl Johnsen d6889569bb Removed FormatInvariant as it's now handled by the extension methods 2025-05-21 09:13:01 +02:00
Carl Johnsen 602a30d8e2 Purged IDb from LocalTestDatabase 2025-05-21 09:11:25 +02:00
Carl Johnsen 60b8df6474 Changed LocalTestDatabase to use factory construction 2025-05-21 09:05:34 +02:00
Carl Johnsen 8c11cc9f71 Removed whitespace 2025-05-21 09:05:15 +02:00
Kenneth SkovhedeandGitHub 1bbe04a782 Merge branch 'master' into feature/add-sqlite-cache-value 2025-04-25 13:58:24 +02:00
Kenneth Skovhede 2ef04e43ee Simplified new ArchiveTime column to not allow null 2025-04-24 20:30:08 +02:00
Kenneth Skovhede 46f5efd178 Merge branch 'master' into feature/support-glacier-style-non-readable-files 2025-04-23 22:37:31 +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 0945657a29 Fixed transaction issue with test handler 2025-04-15 23:24:35 +02:00
Kenneth Skovhede 4773914639 Rewrote testing to use an externally supplied transaction, to avoid temporary transactions from clearing the active transaction.
This is needed because SQLite does not support multiple active transactions.
2025-04-14 12:05:10 +02:00
Kenneth Skovhede 2006556778 Fixed some more nullable support in the database layer 2025-04-03 15:46:20 +02:00
Kenneth Skovhede 7c8571ed33 Added LocalTestDatabase 2025-04-03 09:03:22 +02:00
Kenneth Skovhede fe1cef3be8 Move away from positional parameters in SQL statements.
This is a move away from using positional parameters in SQL statements and rok towards only using named parameters.
2025-03-18 22:41:11 +01:00
Kenneth Skovhede dd07dabee1 Merge commit 'b1f705f71a39e4ea79c7dae56bfd0fb345af5110' into feature/support-glacier-style-non-readable-files 2025-03-18 20:44:05 +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 71b3152f71 Implemented support for not testing archived files 2025-01-29 11:36:45 +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 db517a300b Implemented a fix for compaction issues that could cause inconsistent views of the remote storage. 2024-11-01 14:50:26 +01:00
Kenneth Skovhede 49fb45859c Fixed some incorrectly quoted literals in SQL statements 2024-04-15 08:24:01 +02:00
Kenneth Skovhede 40dd3c6816 Updated all license mentions to MIT 2024-02-28 15:45:30 +01:00
gpatel-frandGitHub 0de4cb7968 allow full-remote-verification to target only list and index files (#5037)
The option is turned into an enum with values True, False, ListIndexes
True and False are for compatibility with the existing backups.
ListIndexes is equivalent to True but don't handle block volumes.
This is to make more workable a strategy of full remote testing
after each backup.
2023-12-10 00:24:07 +01: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
Kenneth Hsu 6f231f9190 Avoid referencing virtual members in Basiclist constructor.
When referencing virtual members in a constructor, the behavior may be
ill-defined as the overridden implementation may depend on uninitialized
instance members.

Since the TABLE_PREFIX, TABLEFORMAT, INSERTCOMMAND, and INSERTARGUMENTS
properties were only referenced in the Basiclist constructor, we can
remove the abstract keyword and provide the values as constructor
parameters.
2018-10-17 20:11:06 -07:00
Kenneth Hsu cb0a3ed2a1 Make constructors for abstract classes protected.
While this does not affect any behavior, it more accurately describes
the accessibility.  Since abstract classes can only be instantiated by
an instance of a derived type, the constructors should at most have
protected access.
2018-04-07 18:04:41 -07:00
Kenneth Skovhede 5919309da9 Added additional checks to attempt to gather information from the remote destination, if the local database is somehow missing the size or hash 2017-02-27 00:43:06 +01:00
Kenneth Skovhede 742eab0913 Fixed multiple cases where connections and command instances were not disposed.
This should fix all cases of "File is locked" on windows.
2016-04-06 20:40:34 +02:00