```
SET max_bytes_before_external_sort = 33554432;
set max_block_size = 1048576;
SELECT number FROM (SELECT number FROM numbers(2097152)) ORDER BY number * 1234567890123456789 LIMIT 2097142, 10;

Code: 49. DB::Exception: Received from localhost:9000. DB::Exception: Pipeline stuck. Current state:
digraph
{
  rankdir="LR";
  { node [shape = box]
    n140555455738912[label="Numbers(2 jobs) (Finished)"];
    n140554936614744[label="Limit(0 jobs) (Finished)"];
    n140554935957656[label="ExpressionTransform(2 jobs) (Finished)"];
    n140554935947416[label="ExpressionTransform(2 jobs) (Finished)"];
    n140554935947736[label="Converting(2 jobs) (Finished)"];
    n140554935957976[label="ExpressionTransform(2 jobs) (Finished)"];
    n140554935472152[label="PartialSortingTransform(2 jobs) (Finished)"];
    n140554935484312[label="LimitsCheckingTransform(2 jobs) (Finished)"];
    n140556954827928[label="MergeSortingTransform(5 jobs) (NeedData)"];
    n140556724839064[label="Limit(0 jobs) (NeedData)"];
    n140556724839704[label="ExpressionTransform(0 jobs) (NeedData)"];
    n140556724840024[label="Converting(0 jobs) (NeedData)"];
    n140554935476248[label="LimitsCheckingTransform(0 jobs) (NeedData)"];
    n140556954548216[label="NullSource(0 jobs) (NeedData)"];
    n140556954546872[label="NullSource(0 jobs) (NeedData)"];
    n140556716210200[label="LazyOutputFormat(0 jobs) (NeedData)"];
    n140556626042904[label="BufferingToFileTransform(4 jobs) (PortFull)"];
    n140556626043544[label="MergingSortedTransform(0 jobs) (NeedData)"];
  }
  n140555455738912 -> n140554936614744;
  n140554936614744 -> n140554935957656;
  n140554935957656 -> n140554935947416;
  n140554935947416 -> n140554935947736;
  n140554935947736 -> n140554935957976;
  n140554935957976 -> n140554935472152;
  n140554935472152 -> n140554935484312;
  n140554935484312 -> n140556954827928;
  n140556954827928 -> n140556724839064;
  n140556954827928 -> n140556626042904;
  n140556724839064 -> n140556724839704;
  n140556724839704 -> n140556724840024;
  n140556724840024 -> n140554935476248;
  n140554935476248 -> n140556716210200;
  n140556954548216 -> n140556716210200;
  n140556954546872 -> n140556716210200;
  n140556626042904 -> n140556626043544;
  n140556626043544 -> n140556954827928;
}
```
master (20.7.1.1)

{
    /** Algorithm:
      * - read to memory blocks from source stream;
      * - if too many of them and if external sorting is enabled,
      *   - merge all blocks to sorted stream and write it to temporary file;
      * - at the end, merge all sorted streams from temporary files and also from rest of blocks in memory.
      */
    
    
    if (description.empty())
    {
        generated_chunk = std::move(chunk);
        return;
    }