[ https://issues.apache.org/jira/browse/CASSANDRA-3465?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13146331#comment-13146331 ]
Alain RODRIGUEZ commented on CASSANDRA-3465: -------------------------------------------- Sorry about the unclearness of my description, don't hesitate to ask me more thing about this issue, I want to fix this asap, so I will help as much as I can. It's the same when trying with CL.ONE, CL.QUORUM or CL.ALL. I think the issue doesn't come from the CL but from the RF, or more accurately from the way that counters replicas are managed. This test code : (3 nodes cluster, 1 CF described below, 5 rows with identical column) /*------------------------------ CODE ---------------------------------------*/ $servers = array("ec2-xxx-xxx-xxx-xxx.eu-west-1.compute.amazonaws.com", "ec2-yyy-yyy-yyy-yyy.eu-west-1.compute.amazonaws.com", "ec2-zzz-zzz-zzz-zzz.eu-west-1.compute.amazonaws.com"); $pool = new ConnectionPool("mykeyspace", $servers); $stats_test = new ColumnFamily($pool, 'test_counter', $read_consistency_level=cassandra_ConsistencyLevel::QUORUM, $write_consistency_level=cassandra_ConsistencyLevel::QUORUM); $time = date( 'YmdH', time()); for($i=0; $i<10; $i++){ for($c=1; $c<=5; $c++){ $stats_test->add($c, $time.':test'); } $counts = $stats_test->multiget(array(1,2,3,4,5)); echo('Counter1: '.$counts[1][$time.':test']."\n"); echo('Counter2: '.$counts[2][$time.':test']."\n"); echo('Counter3: '.$counts[3][$time.':test']."\n"); echo('Counter4: '.$counts[4][$time.':test']."\n"); echo('Counter5: '.$counts[5][$time.':test']."\n\n"); } /*-----------------------END OF CODE ---------------------------------------*/ Gives these outputs: With RF = 1 : Counter1: 1 Counter2: 1 Counter3: 1 Counter4: 1 Counter5: 1 Counter1: 2 Counter2: 2 Counter3: 2 Counter4: 2 Counter5: 2 Counter1: 3 Counter2: 3 Counter3: 3 Counter4: 3 Counter5: 3 Counter1: 4 Counter2: 4 Counter3: 4 Counter4: 4 Counter5: 4 Counter1: 5 Counter2: 5 Counter3: 5 Counter4: 5 Counter5: 5 Counter1: 6 Counter2: 6 Counter3: 6 Counter4: 6 Counter5: 6 Counter1: 7 Counter2: 7 Counter3: 7 Counter4: 7 Counter5: 7 Counter1: 8 Counter2: 8 Counter3: 8 Counter4: 8 Counter5: 8 Counter1: 9 Counter2: 9 Counter3: 9 Counter4: 9 Counter5: 9 Counter1: 10 Counter2: 10 Counter3: 10 Counter4: 10 Counter5: 10 This is the expected behaviour. With RF = 2 : Counter1: 1 Counter2: 1 Counter3: 1 Counter4: 1 Counter5: 1 Counter1: 2 Counter2: 2 Counter3: 2 Counter4: 2 Counter5: 1 Counter1: 3 Counter2: 3 Counter3: 3 Counter4: 3 Counter5: 1 Counter1: 4 Counter2: 4 Counter3: 3 Counter4: 4 Counter5: 2 Counter1: 5 Counter2: 5 Counter3: 3 Counter4: 5 Counter5: 3 Counter1: 6 Counter2: 6 Counter3: 3 Counter4: 6 Counter5: 4 Counter1: 7 Counter2: 7 Counter3: 3 Counter4: 7 Counter5: 5 Counter1: 8 Counter2: 8 Counter3: 4 Counter4: 8 Counter5: 5 Counter1: 9 Counter2: 9 Counter3: 4 Counter4: 9 Counter5: 6 Counter1: 10 Counter2: 10 Counter3: 4 Counter4: 10 Counter5: 6 And if I continue requesting for these counters I will always have 10 on counters 1,2 and 4, but on counter 3 I will have either 4 or 6 alternatively (it is the same with counter 5) With RF = 3 : Counter1: 1 Counter2: 1 Counter3: 1 Counter4: 1 Counter5: 1 Counter1: 2 Counter2: 1 Counter3: 2 Counter4: 2 Counter5: 2 Counter1: 2 Counter2: 2 Counter3: 3 Counter4: 2 Counter5: 3 Counter1: 2 Counter2: 3 Counter3: 4 Counter4: 3 Counter5: 4 Counter1: 3 Counter2: 3 Counter3: 5 Counter4: 3 Counter5: 4 Counter1: 4 Counter2: 3 Counter3: 6 Counter4: 3 Counter5: 5 Counter1: 5 Counter2: 3 Counter3: 7 Counter4: 4 Counter5: 5 Counter1: 6 Counter2: 4 Counter3: 6 Counter4: 5 Counter5: 6 Counter1: 7 Counter2: 5 Counter3: 7 Counter4: 5 Counter5: 7 Counter1: 7 Counter2: 6 Counter3: 8 Counter4: 6 Counter5: 7 Requesting for these rows more times gives me some differents values : Counter1: 7 Counter2: 6 Counter3: 8 Counter4: 6 Counter5: 5 Counter1: 7 Counter2: 9 Counter3: 8 Counter4: 6 Counter5: 5 Here is the "show schema" of my keyspace : create keyspace mykeyspace with placement_strategy = 'SimpleStrategy' and strategy_options = {replication_factor : 2} <-- I changed this value for tests to 1, 2, 3 and durable_writes = true; use mykeyspace; create column family test_counter with column_type = 'Standard' and comparator = 'BytesType' and default_validation_class = 'CounterColumnType' and key_validation_class = 'BytesType' and rows_cached = 0.0 and row_cache_save_period = 0 and row_cache_keys_to_save = 2147483647 and keys_cached = 200000.0 and key_cache_save_period = 14400 and read_repair_chance = 1.0 and gc_grace = 864000 and min_compaction_threshold = 4 and max_compaction_threshold = 32 and replicate_on_write = true and row_cache_provider = 'ConcurrentLinkedHashCacheProvider' and compaction_strategy = 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy'; I think that my cluster is well configured : Address DC Rack Status State Load Owns Token x datacenter1 rack1 Up Normal 59.33 MB 33.33% 0 y datacenter1 rack1 Up Normal 64.45 MB 33.33% 56713727820156407428984779325531226112 z datacenter1 rack1 Up Normal 76.69 MB 33.33% 113427455640312814857969558651062452224 I hope the problem is better explained now. If some point is still unclear, please let me know. > Wrong counters values when RF > 1 > --------------------------------- > > Key: CASSANDRA-3465 > URL: https://issues.apache.org/jira/browse/CASSANDRA-3465 > Project: Cassandra > Issue Type: Bug > Components: Core > Affects Versions: 1.0.0 > Environment: Amazon EC2 (cluster of 5 t1.micro), phpCassa 0.8.a.2 > Reporter: Alain RODRIGUEZ > Assignee: Sylvain Lebresne > Priority: Critical > > I have got a CF that contains many counters of some events. When I'm at RF = > 1 and simulate 10 events, they are well counted. > However, when I switch to a RF = 3, my counter show a wrong value that > sometimes change when requested twice (it can return 7, then 5 instead of 10 > all the time). > I first thought that it was a problem of CL because I seem to remember that I > read once that I had to use CL.One for reads and writes with counters. So I > tried with CL.One, without success... > /*-------------------------------------------------- CODE > -------------------------------------------------------*/ > $servers = array("ec2-xxx-xxx-xxx-xxx.eu-west-1.compute.amazonaws.com", > "ec2-yyy-yyy-yyy-yyy.eu-west-1.compute.amazonaws.com", > "ec2-zzz-zzz-zzz-zzz.eu-west-1.compute.amazonaws.com", > "ec2-aaa-aaa-aaa-aaa.eu-west-1.compute.amazonaws.com", > "ec2-bbb-bbb-bbb-bbb.eu-west-1.compute.amazonaws.com"); > $pool = new ConnectionPool("mykeyspace", $servers); > $stats_test = new ColumnFamily($pool, 'stats_test', > $read_consistency_level=cassandra_ConsistencyLevel::ONE, > $write_consistency_level=cassandra_ConsistencyLevel::ONE); > > $time = date( 'YmdH', time()); > > for($i=0; $i<10; $i++){ > for($c=1; $c<=3; $c++){ > $stats_test->add($c, $time.':test'); > } > $counts = $stats_test->multiget(array(1,2,3)); > echo('Counter1: '.$counts[1][$time.':test']."\n"); > echo('Counter2: '.$counts[2][$time.':test']."\n"); > echo('Counter3: '.$counts[3][$time.':test']."\n\n"); > } > /*-------------------------------- END OF CODE > -------------------------------------------------------------------------*/ > /*-------------------------------------------------- OUTPUT > ------------------------------------------------------------*/ > Counter1: 1 > Counter2: 1 > Counter3: 1 > Counter1: 2 > Counter2: 2 > Counter3: 2 > Counter1: 3 > Counter2: 3 > Counter3: 3 > Counter1: 3 > Counter2: 4 > Counter3: 4 > Counter1: 4 > Counter2: 5 > Counter3: 3 > Counter1: 5 > Counter2: 6 > Counter3: 3 > Counter1: 6 > Counter2: 7 > Counter3: 4 > Counter1: 4 > Counter2: 8 > Counter3: 7 > Counter1: 5 > Counter2: 9 > Counter3: 8 > Counter1: 8 > Counter2: 4 > Counter3: 9 -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira