james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Benoit Tellier <be...@minet.net>
Subject [PATCH] : Fix CassandraUidProvider
Date Wed, 17 Dec 2014 18:19:06 GMT

I found a possible data race on uid generation, in Cassandra's
james-mailbox subproject.

The problem appears when nextUid is called for the first time ( the last
generated uid is equal to 0 ).

The previous code was performing a select on the last uid value.
 - If this value is null, it updates it without checking it.
 - If the value is not null, it updates the value, with a lightweight

I solved the issue by :
 - creating the uid value if the uid is equal to 0. If we can perform
this operation, no one can do, and we can use 1 as next value for uid.
If we fail, someone did that, and we have to update the last uid value
using lightweight transactions ( as if last uid was not null ).
 - I also added a max retry parameter : if we try too update the value
of the uid too many times, a Mailbox exception will be thrown.

You will find the corresponding patch as an attachment.

Sincerly yours,

Benoit Tellier

View raw message