Uploaded image for project: 'Apache IoTDB'
  1. Apache IoTDB
  2. IOTDB-2032

Incorrect result of descending query by multi readers

    XMLWordPrintableJSON

Details

    Description

      By replaying IoTDBTimePartitionIT.testOrderByTimeDesc

      Steps:

      1. Setup a 3 nodes cluster with 2 replicas
      2. Enable time partition with partition_interval 2592000
      3. Prepare the following data

       

      insert into root.group_1.d_1(timestamp, s_1) values(2018-07-18T00:00:00.000+08:00, 18.0);
      insert into root.group_1.d_1(timestamp, s_1) values(2018-07-19T00:00:00.000+08:00, 19.0);
      insert into root.group_1.d_1(timestamp, s_1) values(2019-08-19T00:00:00.000+08:00, 20.0);

      By executing query 

      select * from root.group_1.d_1 order by time desc;

      We got

      The result order is incorrect.

      The main reason is:

      The underlying data has been separated into different partitions, so we use two readers to read them. As we specify the decending order, the reader returns the data in a descending manner. However, in current cluster query, the AssignPathPriorityMergeReader merges the data from mutl readers with a min heap. But we need to use a max heap in a decending query.

      reader1 returns [2019-08-19, 2018-07-19]
      reader2 returns [2018-07-18]
      Use a min heap, it returns 2018-07-18 firstly.
      and then reader2 is empty, it will return 2019-08-19, and 2018-07-19.
      
      If we use a max heap instead, it will return 2019-08-19 firstly.
      And reader1 has 2018-07-19 left, reader2 has 2018-07-18.
      Then 2018-07-19 will be returned because of the max heap.
      The last one is 2018-07-18.

       

      Attachments

        Issue Links

          Activity

            People

              ericpai Eric Pai
              ericpai Eric Pai
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: