Threading issue

Forum for users of SQL Toolkit 3,4,and 5

Threading issue

Postby dmory » Mon Oct 15, 2007 9:50 pm

I've written a custom program to synchronize the database schema changes for all of our production databases. When I modified it run a each synchronization task in a separate thread, it occasionally throws a NullReferenceException:

Here is an example of a stack trace:

10/13/2007 09:30:11.7 , CRIT , Object reference not set to an instance of an object.
10/13/2007 09:30:11.7 , CRIT , RedGate.SQLCompare.Engine
10/13/2007 09:30:11.7 , CRIT , at antlr.ASTFactory.addASTChild(ASTPair currentAST, AST child)
at _14._12()
at _14._11()
at _14._9()
at _14._27()
at _14._26()
at _14._25()
at _14._5()
at _14._2()
at _26._2(String , String , Options )
at RedGate.SQLCompare.Engine.Default._1(String , String , Options )
at RedGate.SQLCompare.Engine.Field._1(Field , Options , SqlCompareOwnerMappings , Boolean , Database )
at RedGate.SQLCompare.Engine.Table.Equals(IDatabaseObject targetObject, Options options, SqlCompareOwnerMappings mappings, Boolean runOnTwo, Database masterDatabase)
at RedGate.SQLCompare.Engine.Database._1(Differences , IDatabaseObjects , IDatabaseObjects , Options , Int32 , Int64 , Int64& , Int32& , SqlCompareOwnerMappings )
at RedGate.SQLCompare.Engine.Database.CompareWith(Database targetDatabase, Options options, SqlCompareOwnerMappings mappings)
at RedGate.SQLCompare.Engine.Database.CompareWith(Database targetDatabase, Options options)
at UpdateManager.LoadDifferences()

The stack trace is not always identical, but it is similar.

These are the dlls I'm using:


Are these libraries guaranteed to be thread-safe? Is this a bug?
Posts: 3
Joined: Mon Oct 15, 2007 9:36 pm

Postby Brian Donahue » Wed Oct 24, 2007 2:16 pm


The SQL Compare Engine is not marked as thread-safe, therefore it should be assumed that it is not. Particularly, using a single Database object from multiple threads can cause problems, as there is some state information maintained in the Database object.
Brian Donahue
Posts: 6590
Joined: Mon Aug 23, 2004 9:48 am

Return to SQL Toolkit Previous Versions

Who is online

Users browsing this forum: No registered users and 0 guests