hawq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m..@apache.org
Subject [1/3] incubator-hawq git commit: HAWQ-376. Fixed QE core dump at HdfsCloseFile() when run stress test with COPY
Date Tue, 02 Feb 2016 03:12:50 GMT
Repository: incubator-hawq
Updated Branches:
  refs/heads/master 210a195c2 -> 6ec1401fa


HAWQ-376. Fixed QE core dump at HdfsCloseFile() when run stress test with COPY


Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/a756a809
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/a756a809
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/a756a809

Branch: refs/heads/master
Commit: a756a8099b65262d26de04ddd6dc52ce060f2bbc
Parents: 210a195
Author: Ming LI <mli@pivotal.io>
Authored: Tue Feb 2 11:07:26 2016 +0800
Committer: Ming LI <mli@pivotal.io>
Committed: Tue Feb 2 11:09:51 2016 +0800

----------------------------------------------------------------------
 src/backend/storage/file/fd.c | 54 +++++++++++++++++++++++++++-----------
 1 file changed, 38 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/a756a809/src/backend/storage/file/fd.c
----------------------------------------------------------------------
diff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c
index b260116..5729941 100644
--- a/src/backend/storage/file/fd.c
+++ b/src/backend/storage/file/fd.c
@@ -632,33 +632,55 @@ LruDelete(File file)
 	if (vfdP->seekPos == INT64CONST(-1))
 		elog(ERROR, "could not get the current position of file \"%s\": %m", vfdP->fileName);
 
-	/* close the file */
-	if (IsLocalPath(VfdCache[file].fileName))
-	{
-		if (close(vfdP->fd))
-			elog(ERROR, "could not close file \"%s\": %m", vfdP->fileName);
-	}
+	/* Need to firstly remove file description from VfdCache before closing file,
+     * So that if we failed to close the file, the metadata is clean, we don't need to re-close
this file. 
+     * otherwise it will crashed if at this time it received die/cancel signal.
+     */
+	size_t tmp_length = vfdP->hProtocol?strlen(vfdP->hProtocol) + 1:1;
+	char protocol[tmp_length];
+	if(tmp_length>1)
+		StrNCpy(protocol, vfdP->hProtocol, tmp_length);
 	else
-	{
-		if (HdfsCloseFile(VfdCache[file].hProtocol, VfdCache[file].hFS,
-				VfdCache[file].hFile))
-		{
-			ereport(WARNING,
-				(errcode(ERRCODE_IO_ERROR),
-						errmsg("could not close file \"%s\": %m", vfdP->fileName),
-						errdetail("%s", HdfsGetLastError())));
-		}
-	}
+		protocol[tmp_length-1]='\0';
+
+	tmp_length = VfdCache[file].fileName?strlen(VfdCache[file].fileName) + 1:1;
+	char filename[tmp_length];
+	if(tmp_length>1)
+		StrNCpy(filename, VfdCache[file].fileName, tmp_length);
+	else
+		filename[tmp_length-1]='\0';
+
+	int fd = vfdP->fd;
+	hdfsFS hfs= vfdP->hFS;
+	hdfsFile hfd = vfdP->hFile;
 
 	--nfile;
 	vfdP->fd = VFD_CLOSED;
 	vfdP->hFS = NULL;
 	vfdP->hFile = NULL;
+
 	if (vfdP->hProtocol)
 	{
 		free(vfdP->hProtocol);
 		vfdP->hProtocol = NULL;
 	}
+
+	/* close the file */
+	if (IsLocalPath(filename))
+	{
+		if (close(fd))
+			elog(ERROR, "could not close file \"%s\": %m", filename);
+	}
+	else
+	{
+		if (HdfsCloseFile(protocol, hfs, hfd))
+		{
+			ereport(WARNING,
+				(errcode(ERRCODE_IO_ERROR),
+						errmsg("could not close file \"%s\": %m", filename),
+						errdetail("%s", HdfsGetLastError())));
+		}
+	}
 }
 
 static void


Mime
View raw message