Line protocol entries ordering affects tick-script

During testing and learning about influxdb and kapacitor, I discovered that when I send a batch of line-protocol entries through the http API for a sensor, where the lines are not sorted in the order of the timestamp, this affects my tick-script stream tasks quite a lot.

When streaming data from that sensor in the tick-script, it seems like I get the values in the same order (in the stream) as they are listed in the line-protocol batch.

When chaining that node into a window() spanning a 10s period, chained into a httpOut() node, I end up with values spanning more than the 10 second period.

Does this sound like something I should report as a bug? Or is sending line-protocol out-of-order with respect to timestamp (even in a single batch) considered something akin to “undefined behavior”, and everything goes in that case?

versions are:
InfluxDB: 1.6.4
Kapacitor: 1.5.2
Telegraf: 1.12.4

I think that sending the line protocol out of order will always result in some strange behavior. One assumption of time series data is that it is in time order.

Even when the timeseries (i.e tag-set) is different? Individually the timeseries values are arriving in time-sorted order in the line-protocol batch. Example to illustrate what I mean can be seen below. There is two series here:

  1. sensor,dimension=leakage,location=js,tag=sensor01,unit=raw
  2. sensor,dimension=pressure,location=js,tag=sensor01,unit=bar

And for the for timeseries number 1 here, the tick-script below windows over 15 seconds of data, not the specified 10 seconds.

Tick-script:

dbrp "test_kapacitor"."autogen"

stream
        | from()
                .measurement(sensor)
        |window()
                .period(10s)
                .every(0s)
        |httpOut(dump)

Line-protocol batch:

sensor,tag=sensor01,unit=bar,dimension=pressure,location=js value=17 0
sensor,tag=sensor01,unit=bar,dimension=pressure,location=js value=20 1000000000
sensor,tag=sensor01,unit=bar,dimension=pressure,location=js value=15 2000000000
sensor,tag=sensor01,unit=bar,dimension=pressure,location=js value=15 3000000000
sensor,tag=sensor01,unit=bar,dimension=pressure,location=js value=15 4000000000
sensor,tag=sensor01,unit=bar,dimension=pressure,location=js value=15 5000000000
sensor,tag=sensor01,unit=bar,dimension=pressure,location=js value=15 6000000000
sensor,tag=sensor01,unit=bar,dimension=pressure,location=js value=15 7000000000
sensor,tag=sensor01,unit=bar,dimension=pressure,location=js value=15 8000000000
sensor,tag=sensor01,unit=bar,dimension=pressure,location=js value=15 9000000000
sensor,tag=sensor01,unit=bar,dimension=pressure,location=js value=15 10000000000
sensor,tag=sensor01,unit=bar,dimension=pressure,location=js value=15 11000000000
sensor,tag=sensor01,unit=bar,dimension=pressure,location=js value=15 12000000000
sensor,tag=sensor01,unit=bar,dimension=pressure,location=js value=15 13000000000
sensor,tag=sensor01,unit=bar,dimension=pressure,location=js value=15 14000000000
sensor,tag=sensor01,unit=bar,dimension=pressure,location=js value=15 15000000000
sensor,tag=sensor01,unit=raw,dimension=leakage,location=js value=1700 0
sensor,tag=sensor01,unit=raw,dimension=leakage,location=js value=2000 1000000000
sensor,tag=sensor01,unit=raw,dimension=leakage,location=js value=1500 2000000000
sensor,tag=sensor01,unit=raw,dimension=leakage,location=js value=1500 3000000000
sensor,tag=sensor01,unit=raw,dimension=leakage,location=js value=1500 4000000000
sensor,tag=sensor01,unit=raw,dimension=leakage,location=js value=1500 5000000000
sensor,tag=sensor01,unit=raw,dimension=leakage,location=js value=1500 6000000000
sensor,tag=sensor01,unit=raw,dimension=leakage,location=js value=1500 7000000000
sensor,tag=sensor01,unit=raw,dimension=leakage,location=js value=1500 8000000000
sensor,tag=sensor01,unit=raw,dimension=leakage,location=js value=1500 9000000000
sensor,tag=sensor01,unit=raw,dimension=leakage,location=js value=1500 10000000000
sensor,tag=sensor01,unit=raw,dimension=leakage,location=js value=1500 11000000000
sensor,tag=sensor01,unit=raw,dimension=leakage,location=js value=1500 12000000000
sensor,tag=sensor01,unit=raw,dimension=leakage,location=js value=1500 13000000000
sensor,tag=sensor01,unit=raw,dimension=leakage,location=js value=1500 14000000000
sensor,tag=sensor01,unit=raw,dimension=leakage,location=js value=1500 15000000000

Results in following dumped output:

{
  "series": [
    {
      "name": "sensor",
      "columns": [
        "time",
        "dimension",
        "location",
        "tag",
        "unit",
        "value"
      ],
      "values": [
        [
          "1970-01-01T00:00:06Z",
          "pressure",
          "js",
          "sensor01",
          "bar",
          15
        ],
        [
          "1970-01-01T00:00:07Z",
          "pressure",
          "js",
          "sensor01",
          "bar",
          15
        ],
        [
          "1970-01-01T00:00:08Z",
          "pressure",
          "js",
          "sensor01",
          "bar",
          15
        ],
        [
          "1970-01-01T00:00:09Z",
          "pressure",
          "js",
          "sensor01",
          "bar",
          15
        ],
        [
          "1970-01-01T00:00:10Z",
          "pressure",
          "js",
          "sensor01",
          "bar",
          15
        ],
        [
          "1970-01-01T00:00:11Z",
          "pressure",
          "js",
          "sensor01",
          "bar",
          15
        ],
        [
          "1970-01-01T00:00:12Z",
          "pressure",
          "js",
          "sensor01",
          "bar",
          15
        ],
        [
          "1970-01-01T00:00:13Z",
          "pressure",
          "js",
          "sensor01",
          "bar",
          15
        ],
        [
          "1970-01-01T00:00:14Z",
          "pressure",
          "js",
          "sensor01",
          "bar",
          15
        ],
        [
          "1970-01-01T00:00:15Z",
          "pressure",
          "js",
          "sensor01",
          "bar",
          15
        ],
        [
          "1970-01-01T00:00:00Z",
          "leakage",
          "js",
          "sensor01",
          "raw",
          1700
        ],
        [
          "1970-01-01T00:00:01Z",
          "leakage",
          "js",
          "sensor01",
          "raw",
          2000
        ],
        [
          "1970-01-01T00:00:02Z",
          "leakage",
          "js",
          "sensor01",
          "raw",
          1500
        ],
        [
          "1970-01-01T00:00:03Z",
          "leakage",
          "js",
          "sensor01",
          "raw",
          1500
        ],
        [
          "1970-01-01T00:00:04Z",
          "leakage",
          "js",
          "sensor01",
          "raw",
          1500
        ],
        [
          "1970-01-01T00:00:05Z",
          "leakage",
          "js",
          "sensor01",
          "raw",
          1500
        ],
        [
          "1970-01-01T00:00:06Z",
          "leakage",
          "js",
          "sensor01",
          "raw",
          1500
        ],
        [
          "1970-01-01T00:00:07Z",
          "leakage",
          "js",
          "sensor01",
          "raw",
          1500
        ],
        [
          "1970-01-01T00:00:08Z",
          "leakage",
          "js",
          "sensor01",
          "raw",
          1500
        ],
        [
          "1970-01-01T00:00:09Z",
          "leakage",
          "js",
          "sensor01",
          "raw",
          1500
        ],
        [
          "1970-01-01T00:00:10Z",
          "leakage",
          "js",
          "sensor01",
          "raw",
          1500
        ],
        [
          "1970-01-01T00:00:11Z",
          "leakage",
          "js",
          "sensor01",
          "raw",
          1500
        ],
        [
          "1970-01-01T00:00:12Z",
          "leakage",
          "js",
          "sensor01",
          "raw",
          1500
        ],
        [
          "1970-01-01T00:00:13Z",
          "leakage",
          "js",
          "sensor01",
          "raw",
          1500
        ],
        [
          "1970-01-01T00:00:14Z",
          "leakage",
          "js",
          "sensor01",
          "raw",
          1500
        ],
        [
          "1970-01-01T00:00:15Z",
          "leakage",
          "js",
          "sensor01",
          "raw",
          1500
        ]
      ]
    }
  ]
}