You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Robert Stupp (JIRA)" <ji...@apache.org> on 2014/06/15 21:16:03 UTC
[jira] [Commented] (CASSANDRA-7400) BATCH with DELETE+INSERT on
same partition key does not work
[ https://issues.apache.org/jira/browse/CASSANDRA-7400?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14032001#comment-14032001 ]
Robert Stupp commented on CASSANDRA-7400:
-----------------------------------------
I understand. Hmm
No way to work around this? For example a new BATCH type ORDERED for example which adds implicit USING _timestamp_ options like this:
{noformat}
begin ORDERED batch
delete from junit.tpc_base where id = 11 using timestamp NOW-3;
insert into junit.tpc_base (id, cid, val) values (11, 10, 'Ursus') using timestamp NOW-2;
insert into junit.tpc_base (id, cid, val) values (11, 12, 'Lucky') using timestamp NOW-1;
insert into junit.tpc_base (id, cid, val) values (11, 2, 'Sooke') using timestamp NOW;
apply batch;
{noformat}
But the drawback of such an _ordered_ is that this may also lead to problems, if there are a lot of statements in the batch.
> BATCH with DELETE+INSERT on same partition key does not work
> ------------------------------------------------------------
>
> Key: CASSANDRA-7400
> URL: https://issues.apache.org/jira/browse/CASSANDRA-7400
> Project: Cassandra
> Issue Type: Bug
> Components: Core
> Reporter: Robert Stupp
> Attachments: BatchDeleteInsertTest.java
>
>
> If within a single batch the all rows for the whole partition key are deleted and inserted again, the batch results with no rows inserted. See example below and attached JUnit.
> {noformat}
> drop keyspace if exists junit;
> create keyspace junit WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 2 };
> create table junit.tpc_base (
> id int, cid int, val text, primary key ( ( id ), cid ) );
> {noformat}
> {noformat}
> begin batch
> delete from junit.tpc_base where id = 11;
> insert into junit.tpc_base (id, cid, val) values (11, 10, 'Ursus');
> insert into junit.tpc_base (id, cid, val) values (11, 12, 'Lucky');
> insert into junit.tpc_base (id, cid, val) values (11, 2, 'Sooke');
> apply batch;
> select * from junit.tpc_base;
> {noformat}
> --> *NO ROWS*
> {noformat}
> begin batch
> delete from junit.tpc_base where id = 11;
> apply batch;
> begin batch
> insert into junit.tpc_base (id, cid, val) values (11, 10, 'Ursus');
> insert into junit.tpc_base (id, cid, val) values (11, 12, 'Lucky');
> insert into junit.tpc_base (id, cid, val) values (11, 2, 'Sooke');
> apply batch;
> select * from junit.tpc_base;
> {noformat}
> --> 3 rows
--
This message was sent by Atlassian JIRA
(v6.2#6252)