2

I was just running few simple tests (inserts and deletes) on column family I created. I observed that while new columns are getting inserted against a row key, but a column that has been recently deleted, does not get inserted.

For example:

rowkey1 :: name1-val1
                 name2-val2

After deleting name1, if I try to insert it again I still get

rowkey1 :: name2-val2 and does not revert back to name1-val1, name2-val2.

The problem occurs when I try to insert it through my code (using Pelops Java client) Following is the code snippet that I use for insertion:

            Mutator mutator = Pelops.createMutator("poolname");
            Column column = new Column(bufcolname);
            column.setValue(bufcolval);
            column.setTimestamp(new Date().getTime());
            mutator.writeColumn("MyColumnFamily",userId, column);
            mutator.execute(ConsistencyLevel.ONE);

Thanks

user1668102
  • 149
  • 8
  • How many nodes are there for this column family and how soon after the delete are you trying to insert the new columns? – Chris Gerken Oct 08 '12 at 11:56
  • Hi Chris, There are 2 nodes and I tried inserting it say after 2-5 minutes. Both the nodes are running on the same machine. BTW this is what fixed the problem.: I changed my code to `List colList = new ArrayList(); for (...) { colList.add(mutator.newColumn(keyname, keyval)); } mutator.writeColumns(COLFAMILY, userId, colList);` – user1668102 Oct 08 '12 at 12:33

1 Answers1

5

Most likely this is a timestamp issue.

If writes conflict, cassandra uses timestamps to decide the winner. In the code above, you are setting the timestamp using milliseconds, but by convention, cassandra uses timestamps in micro seconds.

Timestamps can be anything you like, but microseconds since 1970 is a convention.

So your delete is probably using a timestamp of micro seconds, which is > than the ms timestamp for your add, hence the add will always be shadowed by the delete.

sbridges
  • 24,960
  • 4
  • 64
  • 71