Turn off Query Store stuck

Jason Allen 6 Reputation points
2021-06-03T17:26:39.193+00:00

I tried to turn of the query store on a large transaction database we have, using the command ALTER DATABASE <MyDatabaseName> SET QUERY_STORE = OFF (FORCED)

The query ran for 12 hours before we tried to kill it - now it's been in rollback for 24 hours. It's blocking all backups and index jobs.

Is it safe to restart the sql service or will that result in a huge recovery time? Why would this command take so long to run and/or roll back?

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
14,494 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Hafeez Uddin 296 Reputation points
    2021-06-03T17:56:19.617+00:00

    I will NOT advice you to restart the SQL Service, it will re-do the rollback again and DB recovery may take longer.

    0 comments No comments

  2. Erland Sommarskog 120.2K Reputation points MVP
    2021-06-03T21:44:08.027+00:00

    What does "SELECT @@version" report? This issue seems somewhat familiar., but it may have been fixed.

    For now, I doubt that you have much choice but to restart SQL Server.

    0 comments No comments

  3. Seeya Xi-MSFT 16,571 Reputation points
    2021-06-04T06:28:49.49+00:00

    Hi @Jason Allen ,

    >Is it safe to restart the sql service or will that result in a huge recovery time?

    Normally, it will not be faster and not be safe, because you have to start the recovery again from the beginning of the transaction and determine where to start repairing the database. There may be data corruption in the process.
    Therefore, it is not recommended to restart sql service.
    However, if your environment has node failover, you can refer to this blog:https://blog.sqlauthority.com/2020/03/30/sql-server-unable-to-disable-query-store-for-always-on-database/

    >Why would this command take so long to run and/or roll back?

    Query Store does take up resources to run, it needs to collect information about the query, and build its data storage in the SQL Server database, so it is recommended to try to use the tool during non-working hours.
    Also, you can gather information from DMVs to check whether the process is deadlocked or blocked.
    Please refer to this blog: https://learn.microsoft.com/en-us/troubleshoot/sql/performance/understand-resolve-blocking

    Best regards,
    Seeya


    If the response is helpful, please click "Accept Answer" and upvote it, as this could help other community members looking for similar queries.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.