Make change tracking retention configurable, defaulting to 30 days - #1
Merged
Conversation
Retention was whatever CoreSync's default happened to be - seven days - with no way to see or change it. A client that stays offline longer than that window cannot resume an incremental sync and has to be reinitialized from a fresh snapshot, so the window has to cover how long a device is realistically expected to go without connectivity. Seven days does not. - Add ChangeRetentionDays to SqlServerDataStore, defaulting to 30, with a migration that backfills existing SQL Server data stores. The column is nullable because it belongs to one branch of the TPH hierarchy while the property is not, so without the backfill an existing data store would fail to materialize on a null read. - Pass it to the SqlServerCT configuration builder. Setting it explicitly is also what makes provisioning reconcile the retention on a database that already has change tracking on, where it would otherwise be ignored. - Expose it in the create wizard and the edit page, shown only for native change tracking, validated to 1-365 days on both sides. Saving a new value now issues the ALTER DATABASE and reports the retention read back from the database, so a value that was stored but could not be applied says so instead of showing a green "updated successfully". Also record the reason a sync session failed in the session's own traces. It reached DiagnosticItems already, but nothing led there from the session detail view - which is where anyone investigating a failed session looks first, and where the failures raised before the per-table trace loop showed a session that stopped for no stated reason.
CoreSync#19 is merged, so the submodule can reference main rather than the feature branch it was stacked on. Same tree, so no behaviour change here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Change tracking retention was whatever CoreSync's default happened to be — seven days — with no way to see or change it from the admin UI. A client that stays offline longer than that window cannot resume an incremental sync and has to be reinitialized from a fresh snapshot, so the window has to cover how long a device is realistically expected to go without connectivity. Seven days does not: field crews routinely go a week without a signal, and every one of them comes back to a sync that can never succeed.
What changed
Retention is now a per-data-store setting
ChangeRetentionDaysonSqlServerDataStore, defaulting to 30, with a migration that backfills existing SQL Server data stores. The column is nullable because it belongs to one branch of the TPH hierarchy while the property is not — without the backfill an existing data store would fail to materialize on a null read.SqlServerCTconfiguration builder. Setting it explicitly is also what makes provisioning reconcile the retention on a database that already has change tracking on, where it would otherwise be ignored entirely.Saving actually applies it
Storing the value changes nothing on a database that already has change tracking enabled —
EnableChangeTrackingAsynconly runs when it is off. So saving now issues theALTER DATABASEthrough the newApplyChangeRetentionAsyncand reports the retention read back fromsys.change_tracking_databases. A value that was stored but could not be applied — most often a missingALTER DATABASEpermission — says so, instead of showing a green "updated successfully" over a database that never changed. That failure mode is precisely how this class of bug is created.A failed session says why it failed
SyncSessionService.ErrorAsyncwrote aDiagnosticItembut noSyncSessionTrace. The message reached the Diagnostics page, but nothing led there from the session detail view — which is where anyone investigating a failed session looks first, and where failures raised before the per-table trace loop showed a session that stopped for no stated reason. It now writes both.Worth knowing before merging
MigrationHostedServiceat startup, so no deployment step is needed.Test plan
ALTER DATABASE, confirm the error surfaces rather than a success messageSELECT retention_period, retention_period_units_desc, is_auto_cleanup_on FROM sys.change_tracking_databases WHERE database_id = DB_ID()reflects the new value