Skip to content

HPCC-36047 hthor refactor temporary file handling#21128

Open
streeterd wants to merge 1 commit intohpcc-systems:candidate-10.2.xfrom
streeterd:HPCC-36047_hthor_refactor_temporary_file_cleanup
Open

HPCC-36047 hthor refactor temporary file handling#21128
streeterd wants to merge 1 commit intohpcc-systems:candidate-10.2.xfrom
streeterd:HPCC-36047_hthor_refactor_temporary_file_cleanup

Conversation

@streeterd
Copy link
Copy Markdown
Contributor

@streeterd streeterd commented Mar 23, 2026

Change

A new interface for handling temporary files was created.
hthor was changed to use the new temporary file handler.

Type of change:

  • This change is a bug fix (non-breaking change which fixes an issue).
  • This change is a new feature (non-breaking change which adds functionality).
  • This change improves the code (refactor or other change that does not change the functionality)
  • This change fixes warnings (the fix does not alter the functionality or the generated code)
  • This change is a breaking change (fix or feature that will cause existing behavior to change).
  • This change alters the query API (existing queries will have to be recompiled)

Checklist:

  • My code follows the code style of this project.
    • My code does not create any new warnings from compiler, build system, or lint.
  • The commit message is properly formatted and free of typos.
    • The commit message title makes sense in a changelog, by itself.
    • The commit is signed.
  • My change requires a change to the documentation.
    • I have updated the documentation accordingly, or...
    • I have created a JIRA ticket to update the documentation.
    • Any new interfaces or exported functions are appropriately commented.
  • I have read the CONTRIBUTORS document.
  • The change has been fully tested:
    • I have added tests to cover my changes.
    • All new and existing tests passed.
    • I have checked that this change does not introduce memory leaks.
    • I have used Valgrind or similar tools to check for potential issues.
  • I have given due consideration to all of the following potential concerns:
    • Scalability
    • Performance
    • Security
    • Thread-safety
    • Cloud-compatibility
    • Premature optimization
    • Existing deployed queries will not be broken
    • This change fixes the problem, not just the symptom
    • The target branch of this pull request is appropriate for such a change.
  • There are no similar instances of the same problem that should be addressed
    • I have addressed them here
    • I have raised JIRA issues to address them separately
  • This is a user interface / front-end modification
    • I have tested my changes in multiple modern browsers
    • The component(s) render as expected

Smoketest:

  • Send notifications about my Pull Request position in Smoketest queue.
  • Test my draft Pull Request.

@streeterd streeterd self-assigned this Mar 23, 2026
@streeterd streeterd changed the title hthor refactor temporary file handling HPCC-36047 hthor refactor temporary file handling Mar 23, 2026
@github-actions
Copy link
Copy Markdown

🔄 Upmerge Test Results

Status: ✅ All branches merged successfully
PR: #21128 - hthor refactor temporary file handling
Base Branch: candidate-10.0.x
Test Time: 2026-03-23 11:51:34 UTC

✅ Successful Branches (2)

  • candidate-10.2.x
  • master
    This comment was automatically generated by the upmerge test workflow.

@github-actions
Copy link
Copy Markdown

🔄 Upmerge Test Results

Status: ❌ Conflicts detected
PR: #21128 - HPCC-36047 hthor refactor temporary file handling
Base Branch: candidate-10.0.x
Test Time: 2026-03-23 16:14:48 UTC

How To Resolve❗: Create a PR against conflicting branches and resolve the conflict manually, after the conflicts have been resolved rerun the Upmerge test.

❌ Conflicting Branches (1)

  • master
    This comment was automatically generated by the upmerge test workflow.

@github-actions
Copy link
Copy Markdown

🔄 Upmerge Test Results

Status: ❌ Conflicts detected
PR: #21128 - HPCC-36047 hthor refactor temporary file handling
Base Branch: candidate-10.0.x
Test Time: 2026-03-24 10:53:39 UTC

How To Resolve❗: Create a PR against conflicting branches and resolve the conflict manually, after the conflicts have been resolved rerun the Upmerge test.

❌ Conflicting Branches (1)

  • master
    This comment was automatically generated by the upmerge test workflow.

@github-actions
Copy link
Copy Markdown

🔄 Upmerge Test Results

Status: ❌ Conflicts detected
PR: #21128 - HPCC-36047 hthor refactor temporary file handling
Base Branch: candidate-10.0.x
Test Time: 2026-03-24 13:06:57 UTC

How To Resolve❗: Create a PR against conflicting branches and resolve the conflict manually, after the conflicts have been resolved rerun the Upmerge test.

❌ Conflicting Branches (1)

  • master
    This comment was automatically generated by the upmerge test workflow.

@github-actions
Copy link
Copy Markdown

🔄 Upmerge Test Results

Status: ✅ All branches merged successfully
PR: #21128 - HPCC-36047 hthor refactor temporary file handling
Base Branch: candidate-10.0.x
Test Time: 2026-03-24 16:50:00 UTC

✅ Successful Branches (2)

  • candidate-10.2.x
  • master
    This comment was automatically generated by the upmerge test workflow.

@github-actions
Copy link
Copy Markdown

🔄 Upmerge Test Results

Status: ✅ All branches merged successfully
PR: #21128 - HPCC-36047 hthor refactor temporary file handling
Base Branch: candidate-10.0.x
Test Time: 2026-03-25 11:43:34 UTC

✅ Successful Branches (2)

  • candidate-10.2.x
  • master
    This comment was automatically generated by the upmerge test workflow.

@github-actions
Copy link
Copy Markdown

🔄 Upmerge Test Results

Status: ✅ All branches merged successfully
PR: #21128 - HPCC-36047 hthor refactor temporary file handling
Base Branch: candidate-10.0.x
Test Time: 2026-03-25 14:49:07 UTC

✅ Successful Branches (2)

  • candidate-10.2.x
  • master
    This comment was automatically generated by the upmerge test workflow.

@github-actions
Copy link
Copy Markdown

🔄 Upmerge Test Results

Status: ✅ All branches merged successfully
PR: #21128 - HPCC-36047 hthor refactor temporary file handling
Base Branch: candidate-10.0.x
Test Time: 2026-03-25 17:27:44 UTC

✅ Successful Branches (2)

  • candidate-10.2.x
  • master
    This comment was automatically generated by the upmerge test workflow.

@github-actions
Copy link
Copy Markdown

🔄 Upmerge Test Results

Status: ✅ All branches merged successfully
PR: #21128 - HPCC-36047 hthor refactor temporary file handling
Base Branch: candidate-10.0.x
Test Time: 2026-03-26 10:13:01 UTC

✅ Successful Branches (2)

  • candidate-10.2.x
  • master
    This comment was automatically generated by the upmerge test workflow.

@github-actions
Copy link
Copy Markdown

🔄 Upmerge Test Results

Status: ✅ All branches merged successfully
PR: #21128 - HPCC-36047 hthor refactor temporary file handling
Base Branch: candidate-10.0.x
Test Time: 2026-03-26 10:26:51 UTC

✅ Successful Branches (2)

  • candidate-10.2.x
  • master
    This comment was automatically generated by the upmerge test workflow.

@github-actions
Copy link
Copy Markdown

🔄 Upmerge Test Results

Status: ✅ All branches merged successfully
PR: #21128 - HPCC-36047 hthor refactor temporary file handling
Base Branch: candidate-10.0.x
Test Time: 2026-03-26 10:59:40 UTC

✅ Successful Branches (2)

  • candidate-10.2.x
  • master
    This comment was automatically generated by the upmerge test workflow.

@github-actions
Copy link
Copy Markdown

🔄 Upmerge Test Results

Status: ✅ All branches merged successfully
PR: #21128 - HPCC-36047 hthor refactor temporary file handling
Base Branch: candidate-10.0.x
Test Time: 2026-03-26 11:28:38 UTC

✅ Successful Branches (2)

  • candidate-10.2.x
  • master
    This comment was automatically generated by the upmerge test workflow.

@github-actions
Copy link
Copy Markdown

🔄 Upmerge Test Results

Status: ✅ All branches merged successfully
PR: #21128 - HPCC-36047 hthor refactor temporary file handling
Base Branch: candidate-10.0.x
Test Time: 2026-03-26 11:40:06 UTC

✅ Successful Branches (2)

  • candidate-10.2.x
  • master
    This comment was automatically generated by the upmerge test workflow.

@github-actions
Copy link
Copy Markdown

🔄 Upmerge Test Results

Status: ✅ All branches merged successfully
PR: #21128 - HPCC-36047 hthor refactor temporary file handling
Base Branch: candidate-10.0.x
Test Time: 2026-03-26 11:57:14 UTC

✅ Successful Branches (2)

  • candidate-10.2.x
  • master
    This comment was automatically generated by the upmerge test workflow.

@github-actions
Copy link
Copy Markdown

🔄 Upmerge Test Results

Status: ✅ All branches merged successfully
PR: #21128 - HPCC-36047 hthor refactor temporary file handling
Base Branch: candidate-10.0.x
Test Time: 2026-03-26 11:57:51 UTC

✅ Successful Branches (2)

  • candidate-10.2.x
  • master
    This comment was automatically generated by the upmerge test workflow.

@streeterd streeterd force-pushed the HPCC-36047_hthor_refactor_temporary_file_cleanup branch from 04683e3 to ad2255d Compare March 26, 2026 13:11
@github-actions
Copy link
Copy Markdown

🔄 Upmerge Test Results

Status: ✅ All branches merged successfully
PR: #21128 - HPCC-36047 hthor refactor temporary file handling
Base Branch: candidate-10.0.x
Test Time: 2026-03-26 13:14:18 UTC

✅ Successful Branches (2)

  • candidate-10.2.x
  • master
    This comment was automatically generated by the upmerge test workflow.

@streeterd streeterd force-pushed the HPCC-36047_hthor_refactor_temporary_file_cleanup branch from 4225fb8 to 5987f12 Compare March 26, 2026 13:42
@github-actions
Copy link
Copy Markdown

🔄 Upmerge Test Results

Status: ✅ All branches merged successfully
PR: #21128 - HPCC-36047 hthor refactor temporary file handling
Base Branch: candidate-10.0.x
Test Time: 2026-03-26 13:43:03 UTC

✅ Successful Branches (2)

  • candidate-10.2.x
  • master
    This comment was automatically generated by the upmerge test workflow.

@streeterd
Copy link
Copy Markdown
Contributor Author

streeterd commented Mar 26, 2026

Testing 26th March 2026:

ecl was executed to generate spill files which were generated and removed as expected, see Spill test 26th March 2026 10.04

@streeterd streeterd force-pushed the HPCC-36047_hthor_refactor_temporary_file_cleanup branch from 5987f12 to 4e029c2 Compare March 26, 2026 14:14
@github-actions
Copy link
Copy Markdown

🔄 Upmerge Test Results

Status: ✅ All branches merged successfully
PR: #21128 - HPCC-36047 hthor refactor temporary file handling
Base Branch: candidate-10.0.x
Test Time: 2026-03-26 14:15:19 UTC

✅ Successful Branches (2)

  • candidate-10.2.x
  • master
    This comment was automatically generated by the upmerge test workflow.

@streeterd streeterd force-pushed the HPCC-36047_hthor_refactor_temporary_file_cleanup branch from 4e029c2 to 978d4b5 Compare March 26, 2026 14:29
@github-actions
Copy link
Copy Markdown

🔄 Upmerge Test Results

Status: ✅ All branches merged successfully
PR: #21128 - HPCC-36047 hthor refactor temporary file handling
Base Branch: candidate-10.0.x
Test Time: 2026-03-26 14:30:20 UTC

✅ Successful Branches (2)

  • candidate-10.2.x
  • master
    This comment was automatically generated by the upmerge test workflow.

Copy link
Copy Markdown
Member

@jakesmith jakesmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@streeterd - please see feedback.

Comment thread ecl/eclagent/eclagent.ipp Outdated
private:
friend class EclAgentWorkflowMachine;

struct CTempFileInfo : public CInterfaceOf<IInterface>
Copy link
Copy Markdown
Member

@jakesmith jakesmith Mar 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

somewhat defunct havnig a struct of 1 element.
The tempFileInfoMap could be naturally expressed as:

std::map<std::string, std::strrng> tempFileInfoMap
``

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 4811a5a

Comment thread ecl/eclagent/eclagent.cpp Outdated
return tempFiles.item(idx);
}

Linked<CTempFileInfo> tempFileInfo = tempFileInfoMap.getValue(fname);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be simplified/avoid object etc. - see map comment.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 4811a5a

Comment thread ecl/eclagent/eclagent.cpp Outdated
base.append(PATHSEPCHAR);
StringBuffer tail;
splitFilename(fname, nullptr, nullptr, &tail, nullptr);
tempFileInfo->tempFileName.append(base).append(tail).append(tempOwnerId);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be significantly simplied I think.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 4811a5a

Comment thread ecl/eclagent/eclagent.cpp Outdated
if (tempFileName)
{
Owned<IFile> file = createIFile(tempFileName);
if (file->isFile() != fileBool::foundYes)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably a bit OTT, we know it's a 'file' already.
I thnk should just call file->remove() (NB: createIFile can't return nullptr).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 4811a5a

Comment thread ecl/eclagent/eclagent.cpp Outdated
{
remove(tempFiles.item(idx));
HashIterator it(tempFileInfoMap);
ForEach(it)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again, would be quite a bit simpler with a std::map, for auto, std::strnig etc.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 4811a5a

Comment thread ecl/eclagent/agentctx.hpp Outdated
interface ITempFileHandler
{
virtual const char *noteTemporaryFile(const char * fname) = 0;
virtual const char *queryTemporaryFile(const char * fname) = 0;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: could be a const method.

Copy link
Copy Markdown
Contributor Author

@streeterd streeterd Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fail is not a const, so could not easily change to const, see your comment: #21128 (comment)

Comment thread ecl/eclagent/eclagent.cpp Outdated
{
StringBuffer tempfilename;
getTempfileBase(tempfilename).append(PATHSEPCHAR).append(fname);
if (isEmptyString(fname))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

highly improbably, so if anything, this check can be a dbgassertex(!isEmptyString(fname)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 4811a5a

Comment thread ecl/eclagent/eclagent.cpp Outdated
getTempfileBase(base);
base.append(PATHSEPCHAR);
StringBuffer tail;
splitFilename(fname, nullptr, nullptr, &tail, nullptr);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, passing in a fully qualified name (presumably because might already have temp dir as prefix?), splittnig it, then reconstituing a fully qualified..

The callers should not pass in a fully qualified name, they should pass in a name, and no nothing about the temp dir..

The return is the fully qualified name unique name, which the callers can pass back in to removeTemporaryFile

Comment thread ecl/eclagent/agentctx.hpp Outdated
interface ITempFileHandler
{
virtual const char *noteTemporaryFile(const char * fname) = 0;
virtual const char *queryTemporaryFile(const char * fname) = 0;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

noteTemporaryFile and queryTemporaryFile should take a name , think of it as id. The result is a fully qualified path.
They (the callers) then later call back to removeTemporaryFile with that resulting filename.

So param names and semantics should be clear.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 4811a5a

Comment thread ecl/eclagent/eclagent.cpp Outdated
{
unsigned pid = (unsigned)GetCurrentProcessId();
unsigned __int64 startEpoch = (unsigned __int64)time(nullptr);
tempOwnerId.append('.').append(pid).append('.').append(startEpoch);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it make sense for all temp files to have the same date stamp, irrespective of when noteTemporaryFile is called?
Not sure it does, or make it unique enough.. a simple counter is probably better.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need the pid and startEpoch are required to find out if the process is still alive. pid on it's own is not good enough as the pid is reused. It is also more convienient to have both pid and startEpoch at the end of the file name so that they can be checked easily with an ends with test in the event of file removal after a crash.

Comment thread ecl/eclagent/eclagent.ipp Outdated
MapStringToMyClass<CTempFileInfo> tempFileInfoMap; // Map of original temp file name to the actual temp file name on disk
StringBuffer tempOwnerId; // Holds the current pid and start epoch of the process for temp files in map tempFileInfoMap
CriticalSection tfsect;
TempFilePathByIdMap tempFileNameById; // Map of original temp id to the actual temp file name on disk
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: don't think 'hiding' std::map<std::string, std::string> here with a typedef actually improved readability...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 4811a5a

Comment thread ecl/eclagent/eclagent.cpp Outdated
const char *EclAgent::queryTemporaryFile(const char *name) const
{
dbgassertex(!isEmptyString(fname));
DISLOG("DJPS: queryTemporaryFile(%s)", name);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you prob. meant to use DBGLOG :

not disaster operator logging:

 * 2) For fatal errors or unrecoverable errors:                                         *
 *    DISLOG([LogMsgCode,] format,..)          - uses MCoperatorDisaster                        

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only for testing as the PR was a WIP, now removed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed in 4811a5a

Comment thread ecl/eclagent/eclagent.cpp Outdated
StringBuffer errmsg;
errmsg.append("Attempt to read temp file that has not yet been registered: ").append(tempFileInfo->tempFileName.str());
fail(0, errmsg.str());
errmsg.append("Attempt to read temp file that has not yet been registered: ").append(name);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trivial: VStringBuffer is a nicer pattern for things lke this:

VStringBuffer errmsg("Attempt to read temp file that has not yet been registered: %s", name);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 4811a5a

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 2, 2026

🔄 Upmerge Test Results

Status: ✅ All branches merged successfully
PR: #21128 - HPCC-36047 hthor refactor temporary file handling
Base Branch: candidate-10.0.x
Test Time: 2026-04-02 12:56:44 UTC

✅ Successful Branches (2)

  • candidate-10.2.x
  • master
    This comment was automatically generated by the upmerge test workflow.

@streeterd streeterd force-pushed the HPCC-36047_hthor_refactor_temporary_file_cleanup branch from b5f3457 to 591f31b Compare April 2, 2026 13:15
@streeterd streeterd requested a review from jakesmith April 2, 2026 13:23
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 2, 2026

🔄 Upmerge Test Results

Status: ✅ All branches merged successfully
PR: #21128 - HPCC-36047 hthor refactor temporary file handling
Base Branch: candidate-10.0.x
Test Time: 2026-04-02 13:23:25 UTC

✅ Successful Branches (2)

  • candidate-10.2.x
  • master
    This comment was automatically generated by the upmerge test workflow.

@streeterd streeterd marked this pull request as draft April 2, 2026 13:31
@streeterd streeterd force-pushed the HPCC-36047_hthor_refactor_temporary_file_cleanup branch from 591f31b to 38f3547 Compare April 2, 2026 13:36
@streeterd streeterd changed the base branch from candidate-10.0.x to candidate-10.2.x April 2, 2026 14:02
@streeterd streeterd marked this pull request as ready for review April 2, 2026 14:02
Copy link
Copy Markdown
Member

@jakesmith jakesmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@streeterd - looks close. Please see comments.

Comment thread ecl/eclagent/eclagent.cpp
return nullptr;
}

return inserted.first->c_str();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is thread-safe afaics, as long as tempFileSet entries are not removed or altered (which should be the case). It is probably worth adding a clarifying comment to make it clear to the casual reader of the semantics.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment added in a4755f1

Comment thread ecl/eclagent/eclagent.cpp Outdated
Comment thread ecl/eclagent/eclagent.cpp Outdated
agentMachineCost = getMachineCostRate();

getTempfileBase(tempFilePrefix);
tempFilePrefix.append(PATHSEPCHAR);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: not sure what point of this tempFilePrefix is now, it's same as getTempFileBase, except it has a trailing PATHSEPCHAR ..
getTempFileBase could add a trailing PATHSEPCHAR, and all the places that call it and add one, wouldn't need to (and this code wouldn't be needed).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tempFilePrefix removed in a4755f1

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 2, 2026

🔄 Upmerge Test Results

Status: ✅ All branches merged successfully
PR: #21128 - HPCC-36047 hthor refactor temporary file handling
Base Branch: candidate-10.2.x
Test Time: 2026-04-02 15:49:44 UTC

✅ Successful Branches (1)

  • master
    This comment was automatically generated by the upmerge test workflow.

@streeterd streeterd requested a review from jakesmith April 2, 2026 15:54
Comment thread ecl/eclagent/eclagent.cpp Outdated
}

// The lock is intentionally scoped to insertion; the checks below use only
// the local insertion result and do not access shared state.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is thread-safe afaics, as long as tempFileSet entries are not removed or altered (which should be the case). It is probably worth adding a clarifying comment to make it clear to the casual reader of the semantics.

the new comment doesn't really cover the point I was maknig, but my comment was a bit misleading too, it isn't a thread safety issue as such.

The point I was trying to make was that after a call to noteTemporaryFile the returned const char * is not guaranteed to be valid, e.g. if you call it, then call removeTemporaryFile for the file, the const char * will have been free and using it will likely crash.

Please revise the comment to make it clear that the returned value is only valid if the entry isn't removed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revised in ece7607

Comment thread ecl/eclagent/eclagent.cpp Outdated
StringBuffer &EclAgent::getTempfileBase(StringBuffer &buff)
{
return buff.append(queryTempfilePath()).append(PATHSEPCHAR).appendLower(wuid);
return buff.append(queryTempfilePath()).append(PATHSEPCHAR).appendLower(wuid).append(PATHSEPCHAR);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you haven't checked all uses of getTempFileBase to make sure they don't add double PATHSEPCHAR's now it has been added here.
hint: look at the 'agent.getTempfileBase(tempBase);' use cases in hthor.cpp

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in ece7607

Copy link
Copy Markdown
Member

@jakesmith jakesmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@streeterd - please see comments.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 9, 2026

🔄 Upmerge Test Results

Status: ✅ All branches merged successfully
PR: #21128 - HPCC-36047 hthor refactor temporary file handling
Base Branch: candidate-10.2.x
Test Time: 2026-04-09 14:55:54 UTC

✅ Successful Branches (1)

  • master
    This comment was automatically generated by the upmerge test workflow.

@streeterd streeterd requested a review from jakesmith April 9, 2026 15:03
Comment thread ecl/hthor/hthor.cpp Outdated
RoxieSortAlgorithm sortAlgorithm = isStable ? stableSpillingQuickSortAlgorithm : spillingQuickSortAlgorithm;
StringBuffer tempBase;
agent.getTempfileBase(tempBase);
tempBase.setLength(tempBase.length() - 1); // remove the path separator, as the sort does not want it
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a fragile approach - blindly removing last character ((as in things will break if assumption change).
It would be better to use removeTrailingPathSepChar

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 013d676

Copy link
Copy Markdown
Member

@jakesmith jakesmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@streeterd - If buildTempFilename is the only call to getTempfileBase now.. then it would be more sensible to add the PATHSEPCHAR there I think, and revert the other changes.

@github-actions
Copy link
Copy Markdown

🔄 Upmerge Test Results

Status: ✅ All branches merged successfully
PR: #21128 - HPCC-36047 hthor refactor temporary file handling
Base Branch: candidate-10.2.x
Test Time: 2026-04-10 09:09:27 UTC

✅ Successful Branches (1)

  • master
    This comment was automatically generated by the upmerge test workflow.

@streeterd
Copy link
Copy Markdown
Contributor Author

@streeterd - If buildTempFilename is the only call to getTempfileBase now.. then it would be more sensible to add the PATHSEPCHAR there I think, and revert the other changes.

@jakesmith fixed in 013d676

@streeterd streeterd requested a review from jakesmith April 10, 2026 09:14
@streeterd streeterd force-pushed the HPCC-36047_hthor_refactor_temporary_file_cleanup branch 2 times, most recently from ecd4149 to af8b227 Compare April 10, 2026 14:13
Copy link
Copy Markdown
Member

@jakesmith jakesmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@streeterd - looks good. Please squash.

New temporary file handling interface created.
hthor changed to use the new interface.

Signed-off-by: Dave Streeter <dave.streeter@lexisnexisrisk.com>
@streeterd streeterd force-pushed the HPCC-36047_hthor_refactor_temporary_file_cleanup branch from af8b227 to 1d09e97 Compare April 10, 2026 14:37
@streeterd
Copy link
Copy Markdown
Contributor Author

@streeterd - looks good. Please squash.

@jakesmith squashed.

@github-actions
Copy link
Copy Markdown

🔄 Upmerge Test Results

Status: ✅ All branches merged successfully
PR: #21128 - HPCC-36047 hthor refactor temporary file handling
Base Branch: candidate-10.2.x
Test Time: 2026-04-10 17:00:22 UTC

✅ Successful Branches (1)

  • master
    This comment was automatically generated by the upmerge test workflow.

@github-actions
Copy link
Copy Markdown

🔄 Upmerge Test Results

Status: ✅ All branches merged successfully
PR: #21128 - HPCC-36047 hthor refactor temporary file handling
Base Branch: candidate-10.2.x
Test Time: 2026-04-10 18:38:37 UTC

✅ Successful Branches (1)

  • master
    This comment was automatically generated by the upmerge test workflow.

@github-actions
Copy link
Copy Markdown

🔄 Upmerge Test Results

Status: ✅ All branches merged successfully
PR: #21128 - HPCC-36047 hthor refactor temporary file handling
Base Branch: candidate-10.2.x
Test Time: 2026-04-10 18:39:40 UTC

✅ Successful Branches (1)

  • master
    This comment was automatically generated by the upmerge test workflow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants