1

We have replication set up on a VARBINARY(MAX) column that stores image data (yes, yes, I know - don't blame me, I didn't design it). Recently, we started inserting larger images (around 200kb) and every time it breaks the replication with the following message:

The distribution agent failed to create temporary files in 'C:\Program Files\Microsoft SQL Server\110\COM' directory. System returned errorcode 5. (Source: MSSQL_REPL, Error number: MSSQL_REPL21100)

If I re-initialise the subscription with a new snapshot, everything syncs up fine (including the VARBINARY) and the error goes away. If I then update the VARBINARY column the replication breaks again and we go back to step 1.

The first thing I checked was that the accounts that run the 'SQL Server' and 'SQL Server Agent' services both have full access to the directory - they did.

Next I made sure the server was configured to replicate large VARBINARYs:

-- Set the maximum replication size to unlimited.
EXEC sp_configure 'max text repl size', -1; 
GO
RECONFIGURE; 
GO

This didn't help (I think it was already set to unlimited). What is going on here and how do I fix it?

1 Answer 1

3

After much frustration and fruitless googling, I finally figured out the problem. It was not that the accounts for the 'SQL Server' and 'SQL Server Agent' services did not have access to the directory. The problem was that the account for the 'Log Reader Agent' did not have access. Should have been obvious from the error message, but I just didn't get it...

On the publication server, run this:

USE DatabaseName
EXEC sp_helplogreader_agent

The job_login column will tell you which account runs the Log Reader Agent. Grant that account read/write access to the directory and everything works fine.

2
  • Yep, error 5 is always "Access Denied"
    – Hannah Vernon
    May 26, 2016 at 4:01
  • I have this as part of my standard build script (I have legacy replication) using icacls. I've no idea why this is not granted up front or why I can't configure the directory...
    – gbn
    May 26, 2016 at 6:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.