Test-DbaLsnChain: Fix bug in case log backup is taken during full backup#10185
Test-DbaLsnChain: Fix bug in case log backup is taken during full backup#10185potatoqualitee merged 3 commits intodevelopmentfrom
Conversation
|
@claude please review this pull request |
|
Claude finished @andreasjordan's task in 1m 51s —— View job PR Review: Test-DbaLsnChain LSN Chain Bug Fix
SummaryThis PR fixes a real bug in Core Bug AnalysisThe scenario: When a log backup is taken concurrently with a full backup, the log backup will have:
The old filter logic ( ($_.DatabaseBackupLSN.ToString() -ne $FullDBAnchor.CheckPointLSN) -and ($_.FirstLSN -gt $FullDBAnchor.CheckPointLSN)This incorrectly excluded log-during-full backups because their The new filter logic (line 106): $hasGreaterLastLsn = $_.LastLsn -gt $FullDBAnchor.CheckPointLsnUsing The logic
Verdict: The fix is correct. Formatting / Indentation FixThe Minor Observations1. The verbose log is emitted for every item in The 2. The original code used 3. Pre-existing
4. No newline at end of file — pre-existing issue, not introduced by this PR. ConclusionThe fix correctly identifies the root cause: The PR looks good to merge. |
|
Oh la la @niphlod this seems different from the edge cases we usually refuse so I shall merge |
Type of Change
Invoke-ManualPester)I have a customer facing this issue, so I did some analysis.
Here is the new logging before the fix:
And here is the logging after the fix:
The bug is that a log backup must have a higher FirstLsn than the anchor backup. This is true in most cases so we have not seen this issue. But here in this case, the first log backup that is needed for restore is still based on the "older" full backup, but has a higher LastLsn that the anchor backup and thus needs to be restored as the first log backup.
I also fixed a formatting issue and made the test more readable including a log message for future analysis. That's why I spilt the change into multiple commits for easier review of the change.