cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dan Kinder <>
Subject Reboot: Read After Write Inconsistent Even On A One Node Cluster
Date Mon, 02 Mar 2015 19:44:52 GMT
Hey all,

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'",

        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)


View raw message