Currently, the reading buffers are allocated for a data partition when the first reader connects and are recycled when all readers finish. This strategy may cause starvation if some of the consumer tasks process very slowly and occupy reading buffers for too long, in which scenario, other data partitions may can not allocate enough buffers. We can solve this problem by recycling reading buffers before all readers finish and then allocate those buffers back. If there are other data partitions waiting for reading buffers, they can be fulfilled by the recycled buffers.
Changes
Enable reading buffer floating by recycling earlier before all readers finish.
Motivation
Currently, the reading buffers are allocated for a data partition when the first reader connects and are recycled when all readers finish. This strategy may cause starvation if some of the consumer tasks process very slowly and occupy reading buffers for too long, in which scenario, other data partitions may can not allocate enough buffers. We can solve this problem by recycling reading buffers before all readers finish and then allocate those buffers back. If there are other data partitions waiting for reading buffers, they can be fulfilled by the recycled buffers.
Changes
Enable reading buffer floating by recycling earlier before all readers finish.
Test