[ 
https://issues.apache.org/jira/browse/CASSANDRA-11368?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15199467#comment-15199467
 ] 

Sylvain Lebresne commented on CASSANDRA-11368:
----------------------------------------------

Yes, I can agree that behavior is surprising and it means list inserts are not 
truly idempotent. This is however a downside of the design of lists and to be 
perfectly honest, I'm not sure there is an easy fix for that (though if someone 
has an idea, please share). So I'm not saying it wouldn't be great if this was 
made idempotent, but I'd rather be upfront that unless has a very clever idea, 
this is likely to stay as a known limitation of lists for the foreseeable 
future. Fyi, this is not the only gotcha of lists and we generally advise to 
prefer sets over lists unless you absolutely absolutely need the ordering. And 
even then, make sure a frozen list (which doesn't have this problem) isn't good 
enough for you.

I'll do note that the issue is due to having both statements having the exact 
same timestamp. If you'd use a bigger timestamp for the 2nd insert for 
instance, this would work as expected. The use of UDT has also no impact on 
this. So updating the title to reflect both of those.

> List of UDT can't be updated properly when using USING TIMESTAMP
> ----------------------------------------------------------------
>
>                 Key: CASSANDRA-11368
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-11368
>             Project: Cassandra
>          Issue Type: Bug
>          Components: Core
>            Reporter: Thanh
>
> List of UDT can't be updated properly when using USING TIMESTAMP
> Observe:
> {code}
> cqlsh:t360> CREATE TYPE fullname ( 
> ... fname text, 
> ... lname text 
> ... );
> cqlsh:t360> CREATE TABLE users ( 
> ... id text PRIMARY KEY, 
> ... names list<frozen <fullname>>, 
> ... phone text 
> ... ); 
> cqlsh:t360> UPDATE users USING TIMESTAMP 1458019725701 SET names = [{ fname: 
> 'fname1', lname: 'lname1'},{ fname: 'fname2', lname: 'lname2'},{ fname: 
> 'fname3', lname: 'lname3'}] WHERE id='a'; 
> cqlsh:t360> select * from users;
> id | names | phone 
> ----+--------------------------------------------------------------------------------------------------------------+-------
>  
> a | [{lname: 'lname1', fname: 'fname1'}, {lname: 'lname2', fname: 'fname2'}, 
> {lname: 'lname3', fname: 'fname3'}] | null
> (1 rows) 
> cqlsh:t360> UPDATE users USING TIMESTAMP 1458019725701 SET names = [{ fname: 
> 'fname1', lname: 'lname1'},{ fname: 'fname2', lname: 'lname2'},{ fname: 
> 'fname3', lname: 'lname3'}] WHERE id='a'; 
> cqlsh:t360> select * from users;
> id | names | phone 
> ----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------
>  
> a | [{lname: 'lname1', fname: 'fname1'}, {lname: 'lname2', fname: 'fname2'}, 
> {lname: 'lname3', fname: 'fname3'}, {lname: 'lname1', fname: 'fname1'}, 
> {lname: 'lname2', fname: 'fname2'}, {lname: 'lname3', fname: 'fname3'}] | null
> (1 rows)
> {code}
> => the list doesn't get replaced, it gets appended, which is not the 
> expected/desired result



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to