Skip to content
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

Set-DbaDbCompression, prefer online rebuilds where possible #9118

Merged
merged 6 commits into from
Oct 10, 2023

Conversation

niphlod
Copy link
Contributor

@niphlod niphlod commented Oct 8, 2023

Please read -- recent changes to our repo

On November 10, 2022, we removed some bloat from our repository (for the second and final time). This change requires that all contributors reclone or refork their repo.

PRs from repos that have not been recently reforked or recloned will be closed and @potatoqualitee will cherry-pick your commits and open a new PR with your changes.

  • Please confirm you have the smaller repo (85MB .git directory vs 275MB or 110MB or 185MB .git directory)

Type of Change

  • Bug fix (non-breaking change, fixes # )
  • New feature (non-breaking change, adds functionality, fixes Set-DbaDbCompression to do ONLINE Rebuilds #9102 )
  • Breaking change (affects multiple commands or functionality, fixes # )
  • Ran manual Pester test and has passed (.\tests\manual.pester.ps1)
  • Adding code coverage to existing functionality
  • Pester test is included
  • If new file reference added for test, has is been added to github.com/dataplat/appveyor-lab ?
  • Unit test is included
  • Documentation
  • Build system

Purpose

Try to do online operations where possible.

Approach

There's a swanky "IsOnlineRebuildSupported" on the index property to signal if the version supports online operations. Unfortunately, it's not on the database level.
So, we loop over existing indexes, and if one is found and IsOnlineRebuildSupported is true, we set the relevant flags on the rebuild operation.
Fixes:

  • there was a manual FIX due to a SMO bug for resetting tables to "None", but it seems to be fixed, so I removed the workaround from the code reintroduced, as it seems to be working on AZ but not onprem.

Problems:

  • Azure gets back false on any index, even if AFAIK every Azure instance supports online rebuilds.... so we patch SMO at the top

Possible problems:

  • if you just have heaps, there's no way to detect if online operations are supported if not manually detecting versions and editions
  • technically every index can have that flag .... is there some kind of situation in which one index is rebuildable online and another isn't ? if so, even if AN index is "online rebuildable", this code fails to set it on every operation, and the check must be done on each object and reverted to a clunky "globally I should be able to do it, but I can't for this specific one"... which, in Azure-related cases, is going to be impossible as the property on each index is set to false

Copy link
Member

@wsmelton wsmelton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initial review it looks good, just need to remove duplicated code (see comments)

@niphlod
Copy link
Contributor Author

niphlod commented Oct 8, 2023

thanks @wsmelton , fixed it.

@potatoqualitee
Copy link
Member

Thankyou both!

@potatoqualitee potatoqualitee merged commit 0bfa72b into dataplat:development Oct 10, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Set-DbaDbCompression to do ONLINE Rebuilds
3 participants