Github user paul-guo- commented on a diff in the pull request:

    https://github.com/apache/incubator-hawq/pull/1243#discussion_r117418935
  
    --- Diff: src/backend/executor/nodeMaterial.c ---
    @@ -759,3 +764,30 @@ ExecEagerFreeMaterial(MaterialState *node)
        }
     }
     
    +
    +/*
    + * mkTempFileForWriter
    + * 
    + * Create a unique tmp file for writer. Then use flock's unblock way to 
lock the tmp file.
    + * We can make sure the tmp file will be locked forerver until the writer 
process has quit.
    + */
    +void mkTempFileForWriter(int size, int share_id, char * name)
    +{
    +   char *tmp_file;
    +   int lock;
    +
    +   tmp_file = (char *)palloc(sizeof(char) * MAXPGPATH);
    +   mk_tmp_file_name(tmp_file, size, share_id, name);
    +   elog(DEBUG3, "tmp file for writer is %s", tmp_file);
    +   fd_tmp_writer = open(tmp_file, O_CREAT, S_IRWXU);
    +   if(fd_tmp_writer < 0)
    +   {
    +           elog(ERROR, "could not create tmp file %s for writer", 
tmp_file);
    +   }
    +   lock = flock(fd_tmp_writer, LOCK_EX | LOCK_NB);
    +   if(lock == -1)
    +           elog(DEBUG3, "could not lock tmp file  \"%s\": %m", tmp_file);
    +   else if(lock == 0)
    +           elog(DEBUG3, "successfully locked tmp file  \"%s\": %m", 
tmp_file);
    +   pfree(tmp_file);
    --- End diff --
    
    Please provide more detailed info in log (e.g. this is for shareinputscan, 
fail reason, e.g. strerror(errno)) for debug purpose.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to