commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David J. M. Karlsen" <da...@davidkarlsen.com>
Subject Re: [transaction] Duplicate TX id's
Date Sat, 21 May 2005 16:14:22 GMT
Oliver Zeigermann wrote:

>On 5/20/05, David J. M. Karlsen <david@davidkarlsen.com> wrote:
>  
>
>>Hi!
>>
>>I keep getting ResourceManagerExceptions with "Duplicate transaction
>>id". I took a look at the implementation of FileResourceManager - and
>>generatedUniqueID only returns system.getCurrentMillis() - which isn't
>>random enough in a multithreaded environment.
>>    
>>
>
>Hmmm, I wonder why this is so? Looking at generatedUniqueTxId() it
>checks if the transaction Id already is in use by
>
>            } while (getContext(txId) != null);
>
>Are you sure this is the reason for your exceptions?
>  
>
Hmm, yeah, but still - I cannot see why txId should be unique, the code is:

public String generatedUniqueTxId() throws ResourceManagerSystemException {
        assureRMReady();
        String txId;
        synchronized (globalTransactions) {
            do {
                txId = Long.toHexString(System.currentTimeMillis);
                // XXX busy loop
            } while (getContext(txId) != null);
        }
        return txId;
    }


you can apply my patch.
It uses doomdark.org 's UUIDGenerator. (the site is down at the moment).

>>This should probably be changed into a UUID algorithm or something.
>>    
>>
>
>This would be a good idea in any case :)
>
>  
>
>>Also - the LoggerInterface has a createLogger method - but this is an
>>instance method - so the logging stuff should probably be changed into a
>>factory that creates logger of a specified type?
>>    
>>
>
>Would be cleaner, yes.
>
>  
>
>>I also miss a LoggerFacade for jakarta's own Commons Logging (which
>>would make the other classes redundant).
>>    
>>
>
>Not quite. Commons Logging does not map to the Jakarta Slide logging
>system which makes heavy use of commons transaction. That's why there
>is such a LoggerFacade. Aside, a Commons logging implementation would
>be a good idea :)
>
>  
>
>>Anyone?
>>    
>>
>
>If you could propose any patches I would be happy to consider them ;)
>  
>
I'll have a look into the logging as well.

Mime
View raw message