taosdata / TDengine

High-performance, scalable time-series database designed for Industrial IoT (IIoT) scenarios

Home Page:https://tdengine.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

BUG:Cache bug of the ”last“ function

153952402 opened this issue · comments

Bug Description
When querying specified column data through the last function, the obtained value does not match the expectation. The expected value is false, but the value is true. However, not using the last function can query the correct value

To Reproduce
Steps to reproduce the behavior:

  1. Prepare an SQL A, and run it every second using a while loop
    select Switch as property, _ts from device_table where device_id = 'deviceId1' and Switch is not null and _ts >= {T} and _ts < {T+1} order by _ts desc limit 1 offset 0
    (tips: device_id is a tag)

  2. Prepare an SQL B, and run it every second using a while loop
    select device_id, last(Switch) from device_table where device_id in('deviceId1', 'deviceId2', 'deviceId3') group by device_id

  3. Insert new data through the schemaless model,

  4. See error
    Assume that the initial value of SwitchState is true. After inserting new data, the value becomes false. You will find that the execution result of SQL A will immediately get the latest data 'false', while SQL B will get the expected latest result 'false' only after a varying time of 10-40 seconds.

Environment (please complete the following information):

  • TDengine Version [3.0.7.1]

Additional Context
Add any other context about the problem here.

Uploading 屏幕录制2024-05-30 112331_compressed.mp4…