-
-
Notifications
You must be signed in to change notification settings - Fork 808
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: Get-DbaDbBackupHistory (Break in LSN chain) #7515
Comments
Expected Behavior generate from the SSMS 'Database/Restore/Script' Actual behavior generated by DBATools (seems missing 1 log file) |
@saxet77 - Can you please verify that you get the correct result from @Stuart-Moore - Can you tell me more about this part? |
About your situation: |
@andreasjordan, I will use -IncludeCopyOnly in my script. You think it's need a fix on the Get-DbaDbBackupHistory cmdlet ? |
So here the $FilteredBackupHistory (that is what is in your $backupinformation) is still including the "missing log backup":
Ok, I'll have a deeper look into |
@andreasjordan CheckpointLSN is usuallly the same as FirstLSN and is the LSN to which the backup would be restored to. It's rare to not have them be the same but it can happen Reading those 2 lines I can't remember why they're different. Again, i expect it was another edge case that cropped up @saxet77 is it possible for you to share you backup history? Then we can wrap it into the tests to make it easier to play with/replicate If you could just run: | Export-CliXml -Path c:\somewhere\file.xml and upload it to here, then we can rehydrate it and work with. If you want to obfuscate server and db names that's fine. Really just want the LSNs and the other metadata. |
sorry, mucked up the Markdown in the last comment. Pleae could you upload: I can fake something if needed, but having 'real' data will make sure we have a proper test to stop it coming back again |
Going go need a bit more info please, was concentrating on the restore side to much. Could you dump out the raw backup history for me please? Will need something like: Sorry for the delay, time is being eaten up by a large migration atm. |
Think i now have a fix for this, but it's failing a single test. Need to rebuild my local test rig to work out why. |
Ok, so this is getting annoying. Passes fine locally: But fails in Appveyor. Trying to rdp in and it appears to not be liking the password. Is it not just the one in appveyor.yml anymore? (@andreasjordan or @potatoqualitee can you help here?) |
oh sorry, ill msg you on twitter, stuart |
Gah, it's a bug with 2008r2! That's why it works fine for me. For some reason 2008r2 returns 3 rows of history, others return 4. Both result sets are restoreable though, so that's all that really matters. will fix up tests and push it back up |
haha awesome work! 🚒 |
Yeah, that was confusing the heck out of me. The good news is that the filtering of all back up history is done by select-dbabackupinformation, so we should have consistency between get-dbadbbackuphistory and the restore stack. @saxet77 Really sorry for the delay on this one. Would you be able to take this new branch for a spin and see if it fixes your issue. I think it should, but would be great to know it does. |
Thanks, @Stuart-Moore ! I'll wait for your PR to release 1.1.0 💯 |
Hi @Stuart-Moore, no problem for the delay. |
hey @saxet77 - please close out powershell entirely then without a force, it can look like the new module files are imported, but they arent. |
bummer. thank you for the files, tho. they may be able to help stuart 💯 |
Take 2. Would you mind taking this new version for a spin. It seems to work on the 'msdb' I've hacked together from the files, but need to know it works with a proper one please https://github.com/sqlcollaborative/dbatools/archive/refs/heads/lsnbreak.zip |
Sorry ;( |
@Stuart-Moore Do you have an eye on this? |
Do we still want to try to solve this? Or is the root cause a very rare situation and not worth the effort? Will close this in a few days if there are no dissenting votes. |
I'll defer to @Stuart-Moore |
sometimes stuart gets free cycles, let's hold off to closed this until that time comes up. |
I will close thi now, but can reopen if needed. |
This is still a known issue and should not be closed. |
I finally can reprodure the issue (update: only once and havn't saved it) and will start working on this. Here is my script (that does not work):
Goal is to have a situation where the end of the log backup is after the end of the full backup. This works, but it also needs to have a higher end-lsn than the full backup. And this does not work. Have to stop for today, but will work again on this in the next day. If anyone can help in setting up this situation, I would be glad to hear from you. |
After spending some more time on this I think this picture is a key to understanding the problem. Let me describe the situation and kind of shorten the LSN numbers for better readability:
As @Stuart-Moore and also https://sqlbak.com/academy/backup-chain describe it, the database backup LSN tell us, to which full backup the log backup belongs. So this is coded in line 361 of Get-DbaDbBackupHistory: I managed to manipulate the database backup LSN of the first log backup in my lab and this way the first log backup is not returnd by the command. But I also tested with SSMS and SSMS still returns the first log backup in the list of needed restores. But SSMS only gets all the entries from msdb..backupset and so I don't see the code that returns the list. Maybe they only test based on first LSN and last LSN. If we want to do it like SSMS, then we would need to speak with a nice person at Microsoft and ask for help. Or we say that the database backup LSN of the first log backup is wrong (= it's a bug in SQL Server - that we can not reproduce) and our code is right. Maybe this helps the other contributors (@Stuart-Moore / @wsmelton / @potatoqualitee ) to decide what to do. |
One more update: I could reproduce half of the situation: The first log backup has a lower database backup LSN than expected, but the same end LSN as the full backup. So this log backup is not needed for the restore. As expected dbatools only uses the second log backup and can restore that without problem. SSMS uses first log backup as well, which is not needed and only extra time spend - but without any error, so use would not notice. So do we want the same filtering as SSMS? Maybe they filter on last LSN of log backup must be greater or equal than last LSN of full backup. |
You can trace the t-sql that SSMS is executing if you can get the same backup result set. Microsoft is not hiding it from view. I think it would interesting to know what query filter they have. If it doesn't show one then they are doing it in the application code and it is hidden logic. |
I did start a trace, but found nothing useful. So they do it in the application. Which makes sense as I can select and de-select individual backups. So they only get the complete history once and then slice and dice in the GUI. |
Let me link this blog post as it gives some insight as well: https://www.brentozar.com/archive/2015/12/what-happens-to-transaction-log-backups-during-full-backups/ |
We have the same issue with the missing last log file in |
We have this same problem where a log backup that is needed for restore is tagged as a break in the LSN Chain. Our scenario is just like what's referenced in Brent Ozar's link above. |
@wsmelton @potatoqualitee @Stuart-Moore @andreasjordan fyi.. |
Report
Host used
Errors Received
Steps to Reproduce
Restore Script provide by SSMS 'Restore/Database/Script'
Actual Behavior
Restore Script provide by DBATools (missing 1 log file)
Environmental information
🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
Please provide the output of the below script
SQL Server:
The text was updated successfully, but these errors were encountered: