Testing Get-DbaDbQueryStoreOption - Create the database before anything has read model - #10595
Open
andreasjordan wants to merge 1 commit into
Open
Testing Get-DbaDbQueryStoreOption - Create the database before anything has read model#10595andreasjordan wants to merge 1 commit into
andreasjordan wants to merge 1 commit into
Conversation
…ng has read model The Context added by #10592 created its database after the Contexts that read Query Store on model, and those leave a session parked in model. On the CI runners the next CREATE DATABASE then failed: Could not obtain exclusive lock on database 'model'. Retry the operation later. CREATE DATABASE failed. Some file names listed could not be created. Three attempts, all three the same, so development is red on it. It did not show up in the lab because the run there happened to get the lock. The database is created in the BeforeAll of the Describe now, which runs before any Context, and removed in a new AfterAll. Nothing else changes. The parked session is the leak of #10584. Once that is merged this workaround is no longer needed, but the test should not depend on the order of the Contexts either way. The same care was already taken in the Set-DbaDbQueryStoreOption test of #10593, which is why that one did not break. (do Get-DbaDbQueryStoreOption)
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.
Type of Change
Purpose
developmentis red. TheContextthat #10592 added toGet-DbaDbQueryStoreOption.Tests.ps1creates its database after the Contexts that read Query Store onmodel, and those leave a session parked there. On the runners the nextCREATE DATABASEcannot get the lock:Three attempts, all three the same. It passed in the lab because the run there happened to win the lock, which is exactly what makes this kind of failure easy to merge by accident.
Approach
The database is created in the
BeforeAllof theDescribe, which runs before anyContext, and removed in a newAfterAll. Nothing else changes - no assertion is touched.The cause, and why this is a workaround
The parked session is the connection leak that #10584 fixes:
Invoke-DbaQuery -SqlInstance $server -Database model, whichGet-DbaDbQueryStoreOptionuses per database, orphaned a non-pooled connection that nothing could close. Once that is merged, the ordering here stops mattering - but a test should not depend on the order of its Contexts either way, so this is worth having regardless.This is the third sighting of the same race:
Get-DbaDbRecoveryModelfailing intermittently in a lab run, diagnosed to a session parked inmodelSet-DbaDbCompatibility.Tests.ps1, which already carriesGet-DbaProcess -Database model | Stop-DbaProcessin itsBeforeAll- someone hit it before and worked around it the same wayThe same care was taken in the
Set-DbaDbQueryStoreOptiontest of #10593, which is why that one did not break.Tests
Get-DbaDbQueryStoreOption: 7 tests, all passing, no leftovers in the lab.This text was created by Claude and reviewed by Andreas Jordan.