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

Read after write inconsistent even on single-node cluster

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Low
    • Resolution: Duplicate
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:

      Centos 6.6, Cassandra 2.0.12

    • Severity:
      Low

      Description

      Posted on mailing list, original email:

      I had been having the same problem as in those older post: http://mail-archives.apache.org/mod_mbox/cassandra-user/201411.mbox/%3CCAORswtz+W4Eg2CoYdnEcYYxp9dARWsotaCkyvS5M7+Uo6HT1=A@mail.gmail.com%3E

      To summarize it, on my local box with just one cassandra node I can update and then select the updated row and get an incorrect response.

      My understanding is this may have to do with not having fine-grained enough timestamp resolution, but regardless I'm wondering: is this actually a bug or is there any way to mitigate it? It causes sporadic failures in our unit tests, and having to Sleep() between tests isn't ideal. At least confirming it's a bug would be nice though.

      For those interested, here's a little go program that can reproduce the issue. When I run it I typically see:

      Expected 100 but got: 99
      Expected 1000 but got: 999
      

      — main.go: —

      package main
      
      import (
          "fmt"
      
          "github.com/gocql/gocql"
      )
      
      func main() { 
          cf := gocql.NewCluster("localhost")
          db, _ := cf.CreateSession()
          // Keyspace ut = "update test"         
          err := db.Query(`CREATE KEYSPACE IF NOT EXISTS ut
              WITH REPLICATION = {'class': 'SimpleStrategy',
                                  'replication_factor': 1 }`).Exec()
          if err != nil {                                       
              panic(err.Error())                                        
          }                   
          err = db.Query("CREATE TABLE IF NOT EXISTS ut.test (key text, val text, PRIMARY KEY(key))").Exec()
          if err != nil {        panic(err.Error())                                                                                  }                    
          err = db.Query("TRUNCATE ut.test").Exec()
          if err != nil {           
              panic(err.Error())                                                                              
          }                                                                                                   
          err = db.Query("INSERT INTO ut.test (key) VALUES ('foo')").Exec()                                   
          if err != nil {                                                                                     
              panic(err.Error())                                                                              
          }                           
                                                                                                              
          for i := 0; i < 10000; i++ {                                                                        
              val := fmt.Sprintf("%d", i)                                                                     
              db.Query("UPDATE ut.test SET val = ? WHERE key = 'foo'", val).Exec()                            
                                                                                                              
              var result string
              db.Query("SELECT val FROM ut.test WHERE key = 'foo'").Scan(&result)
              if result != val { 
                  fmt.Printf("Expected %v but got: %v\n", val, result)
              } 
          }                                                                                  
      }
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                dankinder Dan Kinder
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: