Threading issue
dmory
Posts: 5
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:
RedGate.SQL.Shared 5.3.0.2
RedGate.SQLCompare.Engine 5.3.0.44
Are these libraries guaranteed to be thread-safe? Is this a bug?
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:
RedGate.SQL.Shared 5.3.0.2
RedGate.SQLCompare.Engine 5.3.0.44
Are these libraries guaranteed to be thread-safe? Is this a bug?
Comments
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.