SQL Server Agent, Job is locking file meant for deletion

  • Issue: SQL Server 2000 on a 2k3 server. Our backup job has a stipulation to delete any backup iles that are older than x hours. The problem is the file is not being deleted and cannot be manually deleted as the fill seems to have a lock on it like it is in use. The backup jobs are now failing because we are running out of space when the deletion portion of the job is not executed. The only way to remove the lock on the file is to restart the server, which is not a viable daily option. Any ideas are appreciated.

    The logs have been no help. There are no errors other than the latest backup job has failed due to insufficient space on the drive. Thanks all.

  • Suggestions:

    1. Check if anyone is using these databases (sp_lock, or someone is copying these database remotely?);

    2. If no one is using these databases, the only choice may be restart your SQL Agent. If someone is using these databases, try to stop their jobs if possible. 

  • You don't need to restart the server to release the locks on the files...

    Go to computer management and expand Shared Folders tab/Click on Open files and see who is locking them and on the right hand side of the you can right click the file and click close to release them...

    MyComputer/Manage/SharedFolder/Open files/

     

    MohammedU
    Microsoft SQL Server MVP

  • I've also seen this kind of behavior caused by a backup agent that is hung, or in the middle of a backup on the affected file.  In this scenario, the lock is local, and will not show up as an SMB share.

    jg

     

  • Yes...

    If sql backup then you should see SPID...

     

    MohammedU
    Microsoft SQL Server MVP

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply