influxdb icon indicating copy to clipboard operation
influxdb copied to clipboard

[0.9.6-nightly] Distributed Aggregative Query return wrong result in non-fully replicated cluster

Open li-ang opened this issue 11 years ago • 0 comments

Steps to Reproduce Issue:

  1. Create InfluxDB cluster with 3 nodes. There is show servers .
> show servers
id  cluster_addr    raft    raft-leader
1   127.0.0.1:8088  true    true
2   127.0.0.1:9099  true    false
3   127.0.0.1:10101 true    false
  1. Create database and retention policy. The replication of retention policy is 1.
curl -G 'http://127.0.0.1:8086/query' --data-urlencode "q=create database foo"
{"results":[{}]}
curl -G 'http://127.0.0.1:8086/query' --data-urlencode "q=create retention policy one_hour on foo duration 1h replication 1"
{"results":[{}]}
  1. Write some points
curl -X POST 'http://127.0.0.1:8086/write?db=foo&rp=one_hour' --data-binary 'cpu,host=host_2,region=region_2 value=2'
curl -X POST 'http://127.0.0.1:8086/write?db=foo&rp=one_hour' --data-binary 'cpu,host=host_3,region=region_3 value=3'
curl -X POST 'http://127.0.0.1:8086/write?db=foo&rp=one_hour' --data-binary 'cpu,host=host_4,region=region_4 value=4'
curl -G 'http://127.0.0.1:8086/query?pretty=true' --data-urlencode "db=foo" --data-urlencode "q=SELECT * FROM one_hour.cpu"          
{
    "results": [
        {
            "series": [
                {
                    "name": "cpu",
                    "columns": [
                        "time",
                        "host",
                        "region",
                        "value"
                    ],
                    "values": [
                        [
                            "2015-12-03T12:49:58.494620606Z",
                            "host_2",
                            "region_2",
                            2
                        ],
                        [
                            "2015-12-03T12:50:10.815353151Z",
                            "host_3",
                            "region_3",
                            3
                        ],
                        [
                            "2015-12-03T12:50:20.690694532Z",
                            "host_4",
                            "region_4",
                            4
                        ]
                    ]
                }
            ]
        }
    ]
}
  1. Execute aggregative query.
curl -G 'http://127.0.0.1:8086/query?pretty=true' --data-urlencode "db=foo" --data-urlencode "q=SELECT mean(value) FROM one_hour.cpu"
{
    "results": [
        {
            "series": [
                {
                    "name": "cpu",
                    "columns": [
                        "time",
                        "mean"
                    ],
                    "values": [
                        [
                            "1970-01-01T00:00:00Z",
                            2.5
                        ],
                        [
                            "1970-01-01T00:00:00Z",
                            4
                        ]
                    ]
                }
            ]
        }
    ]
}

There are two values for mean functions.Also, other function cloud get similar results

curl -G 'http://127.0.0.1:8086/query?pretty=true' --data-urlencode "db=foo" --data-urlencode "q=SELECT sum(value) FROM one_hour.cpu"
{
    "results": [
        {
            "series": [
                {
                    "name": "cpu",
                    "columns": [
                        "time",
                        "sum"
                    ],
                    "values": [
                        [
                            "1970-01-01T00:00:00Z",
                            5
                        ],
                        [
                            "1970-01-01T00:00:00Z",
                            4
                        ]
                    ]
                }
            ]
        }
    ]
}

li-ang avatar Dec 03 '15 12:12 li-ang