incubator-connectors-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Connectors Framework > How to Write an Output Connector
Date Sun, 24 Oct 2010 16:40:00 GMT
Space: Apache Connectors Framework (https://cwiki.apache.org/confluence/display/CONNECTORS)
Page: How to Write an Output Connector (https://cwiki.apache.org/confluence/display/CONNECTORS/How+to+Write+an+Output+Connector)
Comment: https://cwiki.apache.org/confluence/display/CONNECTORS/How+to+Write+an+Output+Connector?focusedCommentId=24184170#comment-24184170

Comment added by Farzad:
---------------------------------------------------------------------

I seem to had two major problems.  I was caching the thread context, I cleaned them all up.
 The other one is a race condition problem.  Two threads are trying to do an insert, both
fail, they do the second query and find the same max number.  The last txn will fail.  So
I made the second part of my algorithm synchronized.  Same thing happen on the first insert.
 About to make the whole insert method synchronized.  Before doing that I was wondering if
you have other suggestion about solving this problem.  It seems making it synchronized defeats
having multiple threads. My other choice would be to keep another table with the highest dup
numbers and lock it out during a write operation. Thoughts?

In reply to a comment by Karl Wright:
I'd suggest looking very carefully at how you maintain your manager table reference from the
main connector class.  If you look at WebConnector, you will note that it goes out
of its way to avoid keeping around any IThreadContext object, or anything that was "made"
using it, beyond the scope of the setThreadContext(something)/setThreadContext(null) interval. 
If you do wind up inadvertantly persisting something, you've effectively linked it across
threads, which will cause obviously unpredictable results.\\

Change your notification preferences: https://cwiki.apache.org/confluence/users/viewnotifications.action

Mime
View raw message