You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Shahryar Sedghi <sh...@gmail.com> on 2013/04/26 17:26:20 UTC

CQL update and TTL

Apparently when I update a column using CQL that already has a TTL, it
resets the TTL to null, so if there was already a TTL for all columns that
I inserted part of a composite column set, this specific column that I
updated will not expire while the others are are getting expired. Is it how
it is expected to work or it is a bug?

Thanks in advance

Shahryar

Re: CQL update and TTL

Posted by Shahryar Sedghi <sh...@gmail.com>.
The issue is,  I can get the original TTL using the select and use it for
the update, however since TTL can not be dynamic (using ?) it will exhaust
the  prepared statement cache, because I have tons of updates like this and
every one will have a different signature due to changing TTL. I am using
1.2.3 now.

Thanks


On Fri, Apr 26, 2013 at 11:35 AM, Alain RODRIGUEZ <ar...@gmail.com>wrote:

> This seems to be the correct behavior. An update refreshes the TTL, as it
> does in memcache for example. Yet, what I do not know is whether this
> behavior can be changed somehow to let the initial TTL, this might be
> useful on some use cases.
>
> Alain
>
>
> 2013/4/26 Shahryar Sedghi <sh...@gmail.com>
>
>> Apparently when I update a column using CQL that already has a TTL, it
>> resets the TTL to null, so if there was already a TTL for all columns that
>> I inserted part of a composite column set, this specific column that I
>> updated will not expire while the others are are getting expired. Is it how
>> it is expected to work or it is a bug?
>>
>> Thanks in advance
>>
>> Shahryar
>>
>>
>>
>


-- 
"Life is what happens while you are making other plans." ~ John Lennon

Re: CQL update and TTL

Posted by Alain RODRIGUEZ <ar...@gmail.com>.
That is more or less what I was guessing, thanks for these precision.


2013/4/26 Sylvain Lebresne <sy...@datastax.com>

> This is indeed intended. That behavior is largely dictated by how the
> storage engine works, and the fact that an update does no read internally
> in particular.
>
> Yet, what I do not know is whether this behavior can be changed somehow to
>> let the initial TTL,
>>
>
> There's nothing like that supported, no. You have to read the value first
> to get his TTL and then insert whatever update you want with the TTL you've
> just fetch. And since we don't have a good way to do it much more
> efficiently than server side, we prefer not doing it. That way the
> performance impact is very explicit.
>
> --
> Sylvain
>
>
>
>>
>> Alain
>>
>>
>> 2013/4/26 Shahryar Sedghi <sh...@gmail.com>
>>
>>> Apparently when I update a column using CQL that already has a TTL, it
>>> resets the TTL to null, so if there was already a TTL for all columns that
>>> I inserted part of a composite column set, this specific column that I
>>> updated will not expire while the others are are getting expired. Is it how
>>> it is expected to work or it is a bug?
>>>
>>> Thanks in advance
>>>
>>> Shahryar
>>>
>>>
>>>
>>
>

Re: CQL update and TTL

Posted by Sylvain Lebresne <sy...@datastax.com>.
> is there a way to either make TTL dynamic  (using ?)
>

Not at this time. There is
https://issues.apache.org/jira/browse/CASSANDRA-4450 open for that, but
that's not done yet.


> tell the engine not to cache the Prepared statement. I am using the new
> CQL Java Driver.
>

In that case, just don't use a prepared statement. Use a normal, non
prepared query. Yes, normal statements will be slightly slower, but if you
really have to update a column while preserving its TTL, as said above you
will have to do a read followed by a write, so the whole thing won't be
excessively efficient and hence I doubt not using prepared statements will
be the blocking part performance wise.

--
Sylvain



>
>
> Shahryar
>
>
> On Fri, Apr 26, 2013 at 11:42 AM, Sylvain Lebresne <sy...@datastax.com>wrote:
>
>> This is indeed intended. That behavior is largely dictated by how the
>> storage engine works, and the fact that an update does no read internally
>> in particular.
>>
>> Yet, what I do not know is whether this behavior can be changed somehow
>>> to let the initial TTL,
>>>
>>
>> There's nothing like that supported, no. You have to read the value first
>> to get his TTL and then insert whatever update you want with the TTL you've
>> just fetch. And since we don't have a good way to do it much more
>> efficiently than server side, we prefer not doing it. That way the
>> performance impact is very explicit.
>>
>> --
>> Sylvain
>>
>>
>>
>>>
>>> Alain
>>>
>>>
>>> 2013/4/26 Shahryar Sedghi <sh...@gmail.com>
>>>
>>>> Apparently when I update a column using CQL that already has a TTL, it
>>>> resets the TTL to null, so if there was already a TTL for all columns that
>>>> I inserted part of a composite column set, this specific column that I
>>>> updated will not expire while the others are are getting expired. Is it how
>>>> it is expected to work or it is a bug?
>>>>
>>>> Thanks in advance
>>>>
>>>> Shahryar
>>>>
>>>>
>>>>
>>>
>>
>
>
> --
> "Life is what happens while you are making other plans." ~ John Lennon
>

Re: CQL update and TTL

Posted by Shahryar Sedghi <sh...@gmail.com>.
Thanks Sylvain

So how to avoid the prepared statement cache exhaustion, is there a way to
either make TTL dynamic  (using ?) or tell the engine not to cache the
Prepared statement. I am using the new CQL Java Driver.

Shahryar


On Fri, Apr 26, 2013 at 11:42 AM, Sylvain Lebresne <sy...@datastax.com>wrote:

> This is indeed intended. That behavior is largely dictated by how the
> storage engine works, and the fact that an update does no read internally
> in particular.
>
> Yet, what I do not know is whether this behavior can be changed somehow to
>> let the initial TTL,
>>
>
> There's nothing like that supported, no. You have to read the value first
> to get his TTL and then insert whatever update you want with the TTL you've
> just fetch. And since we don't have a good way to do it much more
> efficiently than server side, we prefer not doing it. That way the
> performance impact is very explicit.
>
> --
> Sylvain
>
>
>
>>
>> Alain
>>
>>
>> 2013/4/26 Shahryar Sedghi <sh...@gmail.com>
>>
>>> Apparently when I update a column using CQL that already has a TTL, it
>>> resets the TTL to null, so if there was already a TTL for all columns that
>>> I inserted part of a composite column set, this specific column that I
>>> updated will not expire while the others are are getting expired. Is it how
>>> it is expected to work or it is a bug?
>>>
>>> Thanks in advance
>>>
>>> Shahryar
>>>
>>>
>>>
>>
>


-- 
"Life is what happens while you are making other plans." ~ John Lennon

Re: CQL update and TTL

Posted by Sylvain Lebresne <sy...@datastax.com>.
This is indeed intended. That behavior is largely dictated by how the
storage engine works, and the fact that an update does no read internally
in particular.

Yet, what I do not know is whether this behavior can be changed somehow to
> let the initial TTL,
>

There's nothing like that supported, no. You have to read the value first
to get his TTL and then insert whatever update you want with the TTL you've
just fetch. And since we don't have a good way to do it much more
efficiently than server side, we prefer not doing it. That way the
performance impact is very explicit.

--
Sylvain



>
> Alain
>
>
> 2013/4/26 Shahryar Sedghi <sh...@gmail.com>
>
>> Apparently when I update a column using CQL that already has a TTL, it
>> resets the TTL to null, so if there was already a TTL for all columns that
>> I inserted part of a composite column set, this specific column that I
>> updated will not expire while the others are are getting expired. Is it how
>> it is expected to work or it is a bug?
>>
>> Thanks in advance
>>
>> Shahryar
>>
>>
>>
>

Re: CQL update and TTL

Posted by Alain RODRIGUEZ <ar...@gmail.com>.
This seems to be the correct behavior. An update refreshes the TTL, as it
does in memcache for example. Yet, what I do not know is whether this
behavior can be changed somehow to let the initial TTL, this might be
useful on some use cases.

Alain


2013/4/26 Shahryar Sedghi <sh...@gmail.com>

> Apparently when I update a column using CQL that already has a TTL, it
> resets the TTL to null, so if there was already a TTL for all columns that
> I inserted part of a composite column set, this specific column that I
> updated will not expire while the others are are getting expired. Is it how
> it is expected to work or it is a bug?
>
> Thanks in advance
>
> Shahryar
>
>
>