Skip to content

Fix an edge case in TsdbQuery.getScanEndTimeSeconds() #1581

@ZephyrGuo

Description

@ZephyrGuo
    // Convert to seconds if we have a query in ms.
    if ((end & Const.SECOND_MASK) != 0L) {
      end /= 1000L;
      if (end - (end * 1000) < 1) {
        // handle an edge case where a user may request a ms time between
        // 0 and 1 seconds. Just bump it a second.
        end++;
      }
    }

The condition end - (end * 1000) < 1 is always true in fact. So if we request 1554260399000, we will get 1554267600. The correct result is 1554264000.

Expected end scan time: 1554260400 = 1554260399000/1000 - (1554260399000 / 1000 % 3600) + 3600
Actual end scan time: 1554264000 = (1554260399000/1000 + 1) - ((1554260399000/1000 +1) % 3600) + 3600

1554264000 is one hour behind of 1554260400.

We might scan one more row of data. If we delete data, which may lead to delete more.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions