Dan Kinder created CASSANDRA-8892:
-------------------------------------

             Summary: Read after write inconsistent even on single-node cluster
                 Key: CASSANDRA-8892
                 URL: https://issues.apache.org/jira/browse/CASSANDRA-8892
             Project: Cassandra
          Issue Type: Bug
         Environment: Centos 6.6, Cassandra 2.0.12
            Reporter: Dan Kinder
            Priority: Minor


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:
{noformat}
Expected 100 but got: 99
Expected 1000 but got: 999
{noformat}

--- main.go: ---
{code}
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)
        } 
    }                                                                           
       
}
{code}



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

Reply via email to