You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by Benoit Tellier <be...@minet.net> on 2014/12/17 19:19:06 UTC
[PATCH] : Fix CassandraUidProvider
Hi,
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
transaction.
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
Re: [PATCH] : Fix CassandraUidProvider
Posted by Eric Charles <er...@apache.org>.
Can you attach the patch on a jira for review ? (if not yet done)
On 12/17/2014 07:19 PM, Benoit Tellier wrote:
> Hi,
>
> 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
> transaction.
>
>
>
> 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
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org