Uploaded image for project: 'Cassandra'
  1. Cassandra
  2. CASSANDRA-7801

A successful INSERT with CAS does not always store data in the DB after a DELETE

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Normal
    • Resolution: Fixed
    • Fix Version/s: 2.1.3
    • Labels:
    • Environment:

      PC with Windows 7 and on Linux installation.
      Have seen the fault on Cassandra 2.0.9 and Cassandra 2.1.0-rc5

      Description

      When I run a loop with CQL statements to DELETE, INSERT with CAS and then a GET.
      The INSERT opertion is successful (Applied), but no data is stored in the database. I have checked the database manually after the test to verify that the DB is empty.

              for (int i = 0; i < 10000; ++i)
              {
                  try
                  {
                      t.del();
                      t.cas();
                      t.select();
                  }
                  catch (Exception e)
                  {
                      System.err.println("i=" + i);
                      e.printStackTrace();
                      break;
                  }
              }
      
      
              myCluster = Cluster.builder().addContactPoint("localhost").withPort(12742).build();
              mySession = myCluster.connect();
      
              mySession.execute("CREATE KEYSPACE IF NOT EXISTS castest WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };");
              mySession.execute("CREATE TABLE IF NOT EXISTS castest.users (userid text PRIMARY KEY, name text)");
      
              myInsert = mySession.prepare("INSERT INTO castest.users (userid, name) values ('user1', 'calle') IF NOT EXISTS");
              myDelete = mySession.prepare("DELETE FROM castest.users where userid='user1'");
              myGet = mySession.prepare("SELECT * FROM castest.users where userid='user1'");
          }
      

      I can reproduce the fault with the attached program on a PC with windows 7.
      You need a cassandra runing and you need to set the port in the program.

        Attachments

        1. 7801.txt
          38 kB
          Sylvain Lebresne
        2. 7801-tweak.txt
          8 kB
          Aleksey Yeschenko
        3. cas.zip
          3 kB
          Martin Fransson

          Issue Links

            Activity

              People

              • Assignee:
                slebresne Sylvain Lebresne
                Reporter:
                efrnman Martin Fransson
                Authors:
                Sylvain Lebresne
                Reviewers:
                Aleksey Yeschenko
                Tester:
                Philip Thompson
              • Votes:
                0 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: