Recently I've been debugging a SQL Server 2005 replication setup, where the "Distribution clean up" job for the distributor database was failing. The error message in the agent history was:
Executed as user: <sqlagent_serviceuser>. Could not remove directory <UNC_path_to_snapshot_directory>.
Check the security context of xp_cmdshell and close other processes that may be accessing the directory.
[SQLSTATE 42000] (Error 20015). The step failed.
The “<sqlagent_serviceuser>” was the Windows user that the SQL Server Agent service was running under, while the “<UNC_path_to_snapshot_directory>” was the network path to the directory where snapshots where created.
Looking around on some discussion forums, I found the same message reported several times but without any real solution; at least no solution that would work when I tried to apply it to this particular setup. Most answers to the problem focused on the
xp_cmdshell procedure mentioned in the error, and how it would require certain configuration at the server end.
However, one answer on the MSDN forums did give a useful clue — it pointed to the SQL Books Online article about
Securing the Snapshot Folder (which I should've read right away, really). In a note, this page reads:
If a publication is dropped, replication attempts to remove the snapshot folder under the security context of the SQL Server service account. [...]
It's the SQL Server service account reference which is essential: even though the SQL Agent service account may be the one mentioned in the error message, the actual account that is used to try and delete the snapshot directories is the SQL Server service account instead. Giving that service account the necessary access rights fixed the problem; as in the
Task Scheduler case, accurate error reporting on Microsoft's side might go a long way towards people disliking their software less.
Comments
Mon, 18.08.2008 20:49 CEST
Congratulations!
Mon, 18.08.2008 09:07 CEST
oh my god, one very beautifull feeling.. I know on me :) The happiness! Ozgur
Thu, 03.07.2008 19:36 CEST
Everything's going great with the pregnancy. Only six weeks left now :) It's a hard tim e when you lose a baby, [...]
Tue, 01.07.2008 22:18 CEST
Robertsonian translocation how's thing turn out since las t Sept? I read your story abo ut the baby thing. I am [...]
Mon, 30.06.2008 14:36 CEST
I didn't know there were these kinds of exams. I am new to l inux and still don't know how to do barely anything in [...]
Sun, 06.04.2008 16:59 CEST
You're right, that not only so me, but many questions in the LPI are not up to date and tha t you probably don't use [...]
Fri, 04.04.2008 13:14 CEST
Sure, it does it's job fine (m ost of the time :). And it's straightforward. Why not us e it?
Thu, 27.03.2008 19:53 CET
You still use LILO?!
Thu, 27.03.2008 00:51 CET
Can't you use UUID-naming?
Tue, 18.03.2008 21:45 CET
If it were the old blog, it /m ight/ have been from some comm ent spam. Then again, I cou ldn't find any reference [...]