You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Joris van der Wel <jo...@jorisvanderwel.com> on 2011/08/21 13:38:26 UTC
Questions about TTL and batch_mutate
Hello,
I have a ColumnFamily in which all columns are always set with a TTL,
this would be one of the hottest column families (rows_cached is set
to 1.0). I am wondering if TTL values also follow gc_grace? If they
do, am I correct in thinking it would be best to set gc_grace really
low in this case? (zero?)
Another question:
For a single key I have data in ColumnFamily "CF_A" and ColumnFamily
"CF_B". I set their data in one thrift "batch_mutate".
If I understood correctly, atomicity is then guaranteed (if one
mutation fails, they all fail). But isolation is not. However if for
example the following Mutation takes place:
batch_mutate({
"mykey": {
"CF_A": [
Mutation {
column_or_supercolumn: ColumnOrSuperColumn {
column: {
name: "abc",
value: 10,
timestamp: 1313918714729
}
}
}
],
"CF_B": [
Mutation {
column_or_supercolumn: ColumnOrSuperColumn {
column: {
name: "def",
value: 55,
timestamp: 1313918714730
}
}
},
]
}
}, QUORUM)
The mutation against Column Family "CF_B" is placed last.
If:
get CF_B[def] is 55
Can I then safely assume that
get CF_A[abc] is 10 OR a newer value
Thanks,
Gr. Joris
Re: Questions about TTL and batch_mutate
Posted by Joris van der Wel <jo...@jorisvanderwel.com>.
On Sun, Aug 21, 2011 at 2:21 PM, aaron morton <**...@thelastpickle.com> wrote:
>> I am wondering if TTL values also follow gc_grace?
> They are purged by the first compaction that processes them after TTL has expired. The TTL expiry is used the same way as the expire on a Tombstone.
>
> Thinking out loud, is this possible….
>
> t0 - write col to all 3 replicas.
> t1 - overwrite col with a ttl, write to 2 out of 3 replicas.
> t2 - compaction on all nodes, col removed from 2 out of 3 replicas
> t3 - read at QUORUM, col written in t0 returns.
>
That was the same case I was thinking about. If that case works
properly in cassandra, any value with TTL would also get a tombstone
marker. The value would be cleared after timestamp + TTL + gc_grace.
But if I make sure TTL is always used (enforced in the model layer of
my application), gc_grace=0 would be safe?
> ExpiringColumn sets it localDeletionTime using the ttl, and cfs.removeDeletedStandard() will purge the column.
>
>> The mutation against Column Family "CF_B" is placed last.
>> If:
>> get CF_B[def] is 55
>> Can I then safely assume that
>> get CF_A[abc] is 10 OR a newer value
> The order the changes are applied is undefined (they are pulled from the values of a HashMap). So this should not be relied upon.
Ok, thanks
> Cheers
>
>
> -----------------
> Aaron Morton
> Freelance Cassandra Developer
> @aaronmorton
> http://www.thelastpickle.com
>
> On 21/08/2011, at 11:38 PM, Joris van der Wel wrote:
>
>> Hello,
>>
>> I have a ColumnFamily in which all columns are always set with a TTL,
>> this would be one of the hottest column families (rows_cached is set
>> to 1.0). I am wondering if TTL values also follow gc_grace? If they
>> do, am I correct in thinking it would be best to set gc_grace really
>> low in this case? (zero?)
>>
>> Another question:
>> For a single key I have data in ColumnFamily "CF_A" and ColumnFamily
>> "CF_B". I set their data in one thrift "batch_mutate".
>> If I understood correctly, atomicity is then guaranteed (if one
>> mutation fails, they all fail). But isolation is not. However if for
>> example the following Mutation takes place:
>>
>> batch_mutate({
>> "mykey": {
>> "CF_A": [
>> Mutation {
>> column_or_supercolumn: ColumnOrSuperColumn {
>> column: {
>> name: "abc",
>> value: 10,
>> timestamp: 1313918714729
>> }
>> }
>> }
>> ],
>> "CF_B": [
>> Mutation {
>> column_or_supercolumn: ColumnOrSuperColumn {
>> column: {
>> name: "def",
>> value: 55,
>> timestamp: 1313918714730
>> }
>> }
>> },
>> ]
>> }
>> }, QUORUM)
>>
>> The mutation against Column Family "CF_B" is placed last.
>> If:
>> get CF_B[def] is 55
>> Can I then safely assume that
>> get CF_A[abc] is 10 OR a newer value
>>
>>
>> Thanks,
>> Gr. Joris
>
>
Re: Questions about TTL and batch_mutate
Posted by aaron morton <aa...@thelastpickle.com>.
> I am wondering if TTL values also follow gc_grace?
They are purged by the first compaction that processes them after TTL has expired. The TTL expiry is used the same way as the expire on a Tombstone.
Thinking out loud, is this possible….
t0 - write col to all 3 replicas.
t1 - overwrite col with a ttl, write to 2 out of 3 replicas.
t2 - compaction on all nodes, col removed from 2 out of 3 replicas
t3 - read at QUORUM, col written in t0 returns.
ExpiringColumn sets it localDeletionTime using the ttl, and cfs.removeDeletedStandard() will purge the column.
> The mutation against Column Family "CF_B" is placed last.
> If:
> get CF_B[def] is 55
> Can I then safely assume that
> get CF_A[abc] is 10 OR a newer value
The order the changes are applied is undefined (they are pulled from the values of a HashMap). So this should not be relied upon.
Cheers
-----------------
Aaron Morton
Freelance Cassandra Developer
@aaronmorton
http://www.thelastpickle.com
On 21/08/2011, at 11:38 PM, Joris van der Wel wrote:
> Hello,
>
> I have a ColumnFamily in which all columns are always set with a TTL,
> this would be one of the hottest column families (rows_cached is set
> to 1.0). I am wondering if TTL values also follow gc_grace? If they
> do, am I correct in thinking it would be best to set gc_grace really
> low in this case? (zero?)
>
> Another question:
> For a single key I have data in ColumnFamily "CF_A" and ColumnFamily
> "CF_B". I set their data in one thrift "batch_mutate".
> If I understood correctly, atomicity is then guaranteed (if one
> mutation fails, they all fail). But isolation is not. However if for
> example the following Mutation takes place:
>
> batch_mutate({
> "mykey": {
> "CF_A": [
> Mutation {
> column_or_supercolumn: ColumnOrSuperColumn {
> column: {
> name: "abc",
> value: 10,
> timestamp: 1313918714729
> }
> }
> }
> ],
> "CF_B": [
> Mutation {
> column_or_supercolumn: ColumnOrSuperColumn {
> column: {
> name: "def",
> value: 55,
> timestamp: 1313918714730
> }
> }
> },
> ]
> }
> }, QUORUM)
>
> The mutation against Column Family "CF_B" is placed last.
> If:
> get CF_B[def] is 55
> Can I then safely assume that
> get CF_A[abc] is 10 OR a newer value
>
>
> Thanks,
> Gr. Joris