Skip to content

Fix bug with the incrementing of numbers in temporary file names #1906

@jprestop

Description

@jprestop

Describe the Problem

In installing MET-10.1.0-beta2 on kiowa, Julie encountered a problem when running "make test":

ERROR : 
ERROR : recursive_envs() -> unable to open output file "/tmp/met_config_17562_0"
ERROR :
/d1/projects/MET/MET_releases/met-10.1.0-beta2> ls -l /tmp/met_config_17562_0
-rw-r--r-- 1 jopatz rap 3621 Mar 18 14:35 /tmp/met_config_17562_0

The number 17562 is a process id. Those are supposed to be unique at any given time but can (and are) reused through time. The code is supposed to see that that file exists, and the increment _0 to _1 instead. In general, the MET tools clean up after themselves and remove those temp files. However, if the executable is killed while it's running, it doesn't have a chance to do so.

Here's the function with that logic:

ConcatString make_temp_file_name(const char *prefix, const char *suffix) {

Expected Behavior

The _number after the process id is supposed to increment.

Environment

Describe your runtime environment:
1. Machine: (e.g. HPC name, Linux Workstation, Mac Laptop) kiowa
2. OS: (e.g. RedHat Linux, MacOS) Linux
3. Software version number(s)

To Reproduce

Describe the steps to reproduce the behavior:
This happened in the "make test" stage of the installation of met-10.1.0-beta2. This behavior is difficult to replicate.

  • A simple option is to just test on a feature branch where we tweak the code to NOT include the PID in the filename.
  • We could set MET_TMP_DIR to some local directory, other than tmp, and fill it with all possible met_config_XXXXX_0 filenames, all of which have only Read permission. That should make it fail each time. But we don't know if/what problems we'll run into by having a directory with 100,000 files in it. See Stack Overflow: https://stackoverflow.com/questions/466521/how-many-files-can-i-put-in-a-directory

Relevant Deadlines

None

Funding Source

Split 2792541 and 2702691

Define the Metadata

Assignee

  • Select engineer(s) or no engineer required
  • Select scientist(s) or no scientist required

Labels

  • Select component(s)
  • Select priority
  • Select requestor(s)

Projects and Milestone

  • Select Organization level Project for support of the current coordinated release
  • Select Repository level Project for development toward the next official release or add alert: NEED PROJECT ASSIGNMENT label
  • Select Milestone as the next bugfix version

Define Related Issue(s)

Consider the impact to the other METplus components.

Bugfix Checklist

See the METplus Workflow for details.

  • Complete the issue definition above, including the Time Estimate and Funding Source.
  • Fork this repository or create a branch of main_<Version>.
    Branch name: bugfix_<Issue Number>_main_<Version>_<Description>
  • Fix the bug and test your changes.
  • Add/update log messages for easier debugging.
  • Add/update unit tests.
  • Add/update documentation.
  • Push local changes to GitHub.
  • Submit a pull request to merge into main_<Version>.
    Pull request: bugfix <Issue Number> main_<Version> <Description>
  • Define the pull request metadata, as permissions allow.
    Select: Reviewer(s) and Linked issues
    Select: Organization level software support Project for the current coordinated release
    Select: Milestone as the next bugfix version
  • Iterate until the reviewer(s) accept and merge your changes.
  • Delete your fork or branch.
  • Complete the steps above to fix the bug on the develop branch.
    Branch name: bugfix_<Issue Number>_develop_<Description>
    Pull request: bugfix <Issue Number> develop <Description>
    Select: Reviewer(s) and Linked issues
    Select: Repository level development cycle Project for the next official release
    Select: Milestone as the next official version
  • Close this issue.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions