Remote Download error - Unclosed quotation mark after the character string '%$au'


PROBLEM:

I am getting an error when the remote downloads: Unclosed quotation mark after the character '%$au'

If I delete the generated package on the server, the package is created and downloaded no issues.

If I try to download again (not generating the package on server) the error occurs.

I have tried multiple download packages. I have tried turning off differential downloads. I am at a loss.

I can't see any data that would have this $au value anywhere.

There are no new logs entries on the server when the download fails.

The following is the error on the record when the download fails:

2021-03-30 20:08:33.9353Z Error NAOU23788 BENTLEY\Dan.Hillman Ivara.Replication.Remote.Synchronizer.Client [14] Synchronization Failure EXCEPTION OCCURRED:SqlException Unclosed quotation mark after the character string '%$au'.
Incorrect syntax near '%$au'.    at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
   at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted)
   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
   at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
   at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
   at Ivara.Replication.Remote.Synchronizer.Client.CheckIfFullDownLoadIsRequired(SynchronizationHistory currentSH)
   at Ivara.Replication.Remote.Synchronizer.Client.Synchronize()

SOLUTION:

There is a limit to the length of the string that is generated in the query that creates the backup table names.  It gets truncated when the database name is too long and the trailing single quote is lost.  The database name must be shorter than or the same length as  'IvaraRemote'.  Because the string is fixed length but the various components that are appended to it are different lengths I can only guarantee that IvaraRemote  (11 characters) database name length or shorter will work.  As the remote database table name lengths change during releases and we test with that database name we will catch this error if a table name gets too long but we don't test all possible database names lengths.