From cfb3a7217fcc708561dc76d20784c078cf46b1e4 Mon Sep 17 00:00:00 2001 From: ztao1987 Date: Wed, 23 Feb 2022 09:26:19 +0800 Subject: [PATCH] HAWQ-1831. fix core issue when metadatacache disabled --- src/backend/cdb/cdbdatalocality.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/backend/cdb/cdbdatalocality.c b/src/backend/cdb/cdbdatalocality.c index 7fd620963..5a6615de7 100644 --- a/src/backend/cdb/cdbdatalocality.c +++ b/src/backend/cdb/cdbdatalocality.c @@ -1442,8 +1442,8 @@ fetch_hdfs_data_block_location(char *filepath, int64 len, int *block_num, *hit_ratio = 0.0; return NULL; } - BlockLocation *locations; - HdfsFileInfo *file_info; + BlockLocation *locations = NULL; + HdfsFileInfo *file_info = NULL; //double hit_ratio; uint64_t beginTime; beginTime = gettime_microsec(); @@ -1461,7 +1461,12 @@ fetch_hdfs_data_block_location(char *filepath, int64 len, int *block_num, } DestroyHdfsFileInfo(file_info); } else { - locations = HdfsGetFileBlockLocations(filepath, len, block_num); + BlockLocation *hdfs_locations = HdfsGetFileBlockLocations(filepath, len, block_num); + locations = CreateHdfsFileBlockLocations(hdfs_locations, *block_num); + if (hdfs_locations) + { + HdfsFreeFileBlockLocations(hdfs_locations, *block_num); + } } if (debug_print_split_alloc_result) { uint64 endTime = gettime_microsec();