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

Update Set-DbaDbQueryStoreOption.ps1 #9205

Merged

Conversation

tominyorks
Copy link
Contributor

Ignore snapshots when setting Query Store options

Set-DbaDbQueryStoreOptions uses ALTER DATABASE statements under the hood, and these fail when run against a read only database snapshot. Update the call to Get-DbaDatabase to exclude snapshots upfront.

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 Set-DbaDbQueryStoreOption fails if database snapshots exist and aren't explicitly excluded #9203 )
  • New feature (non-breaking change, adds functionality, fixes # )
  • 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

Stop Set-DbaDbQueryStoreOption from failing when a database snapshot exists but isn't explicitly added to an exclusion list

Approach

Excludes database snapshots when retrieving the available databases from an instance

Commands to test

Set-DbaDbQueryStoreOption is the only command affected.

Running the below, targeting a SQL instance that hosts at least one database snapshot will no longer error in the fixed version. Note, this will enable Query Store on all databases unless the -Database parameter is also provided.

Set-DbaDbQueryStoreOption -SqlInstance localhost `
    -State ReadWrite `
    -StaleQueryThreshold 90 `
    -FlushInterval 900 `
    -CollectionInterval 30 `
    -MaxSize 500 `
    -MaxPlansPerQuery 200 `
    -WaitStatsCaptureMode On

Ignore snapshots when setting Query Store options

Set-DbaDbQueryStoreOptions uses ALTER DATABASE statements under the hood,
and these fail when run against a read only database snapshot. Update
the call to Get-DbaDatabase to exclude snapshots upfront.
Removed unnecessary parenthesis for clarity
@potatoqualitee
Copy link
Member

hey nice, thank you both 💯 !

@potatoqualitee potatoqualitee merged commit 56d716a into dataplat:development Jan 13, 2024
2 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-DbaDbQueryStoreOption fails if database snapshots exist and aren't explicitly excluded
3 participants