Options

Compare Database throws NullReferenceException

MarkLFTMarkLFT Posts: 15
I have a Windows Service application, that runs continuously. The app will check for differences between two databases, and the syncs the changes from DB2 to Db1.

We use the DataCompare SDK to do this.

The service will run for days, sometimes weeks with no problem. But then without warning, it will throw a NullReferenceException on the command

session.CompareDatabases(db1, db2, mappings);

If I restart the service it will sometimes go away, sometimes it will come back immediately. Other times the problem will fix it self after a couple of hours. But then reoccur a few hours later.

The job runs every few minutes, and is identical in its settings for every run. So I find it confusing that we would get these errors so intermittently.

Can you please offer any advice, on how I can pint down the route cause.

To help I have attached a Stack trace from one of the errors.
#8ZK.#7ZK #pmc(String #A2Tb, String #K12b, String #aLPb, Boolean #NMrc):330
#8ZK.#pmc #89K(String #1Z, String #y0, FieldPair #M9rc, Boolean #N9rc):97
#8ZK.#pmc #89K(IComparable #WfVb, IComparable #H12b, FieldPair #M9rc, Boolean #N9rc, Boolean #O9rc):397
RedGate.SQLDataCompare.Engine.ResultsStore.Store IdenticalValues(Object value1, Object value2, FieldPair fieldPair, Boolean forceBinaryString, Boolean roundDoubles, Boolean treatEmptyStringAsNull):434
RedGate.SQLDataCompare.Engine.ComparisonSession #paL(Int32 #39rc, Object[] #09rc, Object[] #19rc, IList`1 #49rc, DifferencesSummary #59rc, Byte[] #29rc, Boolean #N9rc, Boolean #O9rc, Boolean #69rc):17
RedGate.SQLDataCompare.Engine.ComparisonSession #maL(#H1K #X9rc, #H1K #Y9rc, TableMapping #3Krc, ProgressPercentageTracker #luPb):0
RedGate.SQLDataCompare.Engine.ComparisonSession CompareDatabases(Database db1, Database db2, TableMappings mappings, SessionSettings sessionSettings, Boolean doNotBeDefeated):1570
RedGate.SQLDataCompare.Engine.ComparisonSession CompareDatabases(Database db1, Database db2, TableMappings mappings, SessionSettings sessionSettings):0
RedGate.SQLDataCompare.Engine.ComparisonSession CompareDatabases(Database db1, Database db2, TableMappings mappings):0
D:\_My Projects\Resort Manager\Dev\ResortManager\Utility Apps\RedGateWrapper\RedGateWrapper\SQLDataCompare.cs:190 in `SynchronizeData(IList`1 tableNames, SelectionDelegateType delegateType, TableMappingsType mappingsType, MappingOptions mappingOptions, Boolean applyWhereClause)`

[/code]

Comments

  • Options
    Brian DonahueBrian Donahue Posts: 6,590 Bronze 1
    Hello,

    It's hard to say from the stack trace, but it looks like something to do with collations or not knowing what the collation of the database is. Depends on if you are comparing scripts, or scripts to live databases, or something in the code. Scripts folders should have the table schema and the RedGateDatabaseInfo.xml file which should set the collation.

    Or you could bypass the whole issue and use the option to do a binary comparison, but then it compares text case-sensitively and including white space and you may not want that.

    Like with all null-ref exceptions, you want to debug and look at the local variables to see if anything is set to null and if those variables are being used. So the stack trace is part of the troubleshooting but I can't draw any definitive conclusions from it.
  • Options
    Hi,

    We are not comparing to scripts, we are comparing a database tables with another database tables.

    In the command CompareDatabases() there are only three parameters, db1, db2, and mapping. I have checked these and the are not null, I also checked the properties of these three objects, and none of the properties are null.

    With regards to going further into the stack trace, as you can see, all the methods have been obfuscated. I am guess by you guys.

    I will check the collation settings, but I am sure they are the same on both servers.

    Thanks
  • Options
    Brian DonahueBrian Donahue Posts: 6,590 Bronze 1
    I can decode the stack frames at my end and the method names do point towards a problem with collations.

    If you don't have any joy, I'll email you a link to our debugging tool and that may help.
Sign In or Register to comment.