HAWQ-1408. Fixed crash when alloc not enough segno for write
HAWQ-1408. Fixed crash when alloc not enough segno for write

This fix includes below changes:
(1) When keepHash, we can not guarantee that only generate remaining_num is enough to alloc seg file for all segment_num. Because the next new generated seg file number may have same hash key id with the old one.
(2) When !keepHash, now the remaining_num returned from addCandidateSegno() is not precise. So we need to fix it to meet the need of HAWQ-642.
(3) At the final call to addCandidateSegno(), we should keep monitoring the remaining_num instead of at the beginning because of the reason (1). So that even the new seg file is not actually used by this query ( maybe for hash key conflict), we can continue to alloc enough seg files for this query.

jianlirong/incubator-hawq,jianlirong/incubator-hawq,huor/incubator-hawq,jianlirong/incubator-hawq,huor/incubator-hawq,outofmem0ry/incubator-hawq,jianlirong/incubator-hawq,wengyanqing/incubator-hawq,stanlyxiang/incubator-hawq,huor/incubator-hawq,lavjain/incubator-hawq,outofmem0ry/incubator-hawq,jianlirong/incubator-hawq,wengyanqing/incubator-hawq,lavjain/incubator-hawq,outofmem0ry/incubator-hawq,lavjain/incubator-hawq,huor/incubator-hawq,stanlyxiang/incubator-hawq,stanlyxiang/incubator-hawq,huor/incubator-hawq,stanlyxiang/incubator-hawq,stanlyxiang/incubator-hawq,lavjain/incubator-hawq,lavjain/incubator-hawq,jianlirong/incubator-hawq,lavjain/incubator-hawq,wengyanqing/incubator-hawq,wengyanqing/incubator-hawq,jianlirong/incubator-hawq,jianlirong/incubator-hawq,outofmem0ry/incubator-hawq,stanlyxiang/incubator-hawq,outofmem0ry/incubator-hawq,outofmem0ry/incubator-hawq,wengyanqing/incubator-hawq,stanlyxiang/incubator-hawq,huor/incubator-hawq,huor/incubator-hawq,lavjain/incubator-hawq,wengyanqing/incubator-hawq,outofmem0ry/incubator-hawq,wengyanqing/incubator-hawq,wengyanqing/incubator-hawq,lavjain/incubator-hawq,outofmem0ry/incubator-hawq