locked
Could not obtain exclusive lock on database ‘model’. RRS feed

  • Question

  • SQL 2014 instance, cannot create the database, but the restore and attach are normal, 

    May I ask what is the following question?

    Could not obtain exclusive lock on database ‘model’. Retry the operation later. CREATE DATABASE failed

    Tuesday, October 16, 2018 2:43 PM

Answers

  • https://blogs.msdn.microsoft.com/poojakamath/2014/12/23/could-not-obtain-exclusive-lock-on-database-model-retry-the-operation-later-create-database-failed/

    Best Regards,Uri Dimant SQL Server MVP, http://sqlblog.com/blogs/uri_dimant/

    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting: Large scale of database and data cleansing
    Remote DBA Services: Improves MS SQL Database Performance
    SQL Server Integration Services: Business Intelligence

    Tuesday, October 16, 2018 2:48 PM
    Answerer
  • Hi Nico_Nico_Ni,

    When we create a database, it will use model database to initialize the database. In this process, it requires setting a exclusive lock on model database. When we cannot obtain the lock, we will meet this error.

    Please use the following query to check if the model database is using by other session:

    SELECT request_session_id FROM 
    sys.dm_tran_locks 
    WHERE resource_database_id = 
    DB_ID('Model')

    If some other session is using it, please use DBCC InputBuffer(<session_id>) checking it.

    Then we can kill this session based on the environment.

    Best Regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by Nico_Nico_Ni Wednesday, October 17, 2018 12:14 AM
    Tuesday, October 16, 2018 11:32 PM

All replies

  • https://blogs.msdn.microsoft.com/poojakamath/2014/12/23/could-not-obtain-exclusive-lock-on-database-model-retry-the-operation-later-create-database-failed/

    Best Regards,Uri Dimant SQL Server MVP, http://sqlblog.com/blogs/uri_dimant/

    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting: Large scale of database and data cleansing
    Remote DBA Services: Improves MS SQL Database Performance
    SQL Server Integration Services: Business Intelligence

    Tuesday, October 16, 2018 2:48 PM
    Answerer
  • Hi Nico_Nico_Ni,

    When we create a database, it will use model database to initialize the database. In this process, it requires setting a exclusive lock on model database. When we cannot obtain the lock, we will meet this error.

    Please use the following query to check if the model database is using by other session:

    SELECT request_session_id FROM 
    sys.dm_tran_locks 
    WHERE resource_database_id = 
    DB_ID('Model')

    If some other session is using it, please use DBCC InputBuffer(<session_id>) checking it.

    Then we can kill this session based on the environment.

    Best Regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by Nico_Nico_Ni Wednesday, October 17, 2018 12:14 AM
    Tuesday, October 16, 2018 11:32 PM