cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dan Kinder (JIRA)" <>
Subject [jira] [Created] (CASSANDRA-8892) Read after write inconsistent even on single-node cluster
Date Mon, 02 Mar 2015 23:53:05 GMT
Dan Kinder created CASSANDRA-8892:

             Summary: Read after write inconsistent even on single-node cluster
                 Key: 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:

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 (


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 {                                       
    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 {           
    err = db.Query("INSERT INTO ut.test (key) VALUES ('foo')").Exec()                    
    if err != nil {                                                                      
    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)

This message was sent by Atlassian JIRA

View raw message