Skip to content

[68] Improve lockfile handling - #114

Draft
Lagejohn wants to merge 8 commits into
mainfrom
68-fix-stuck-lockfile
Draft

[68] Improve lockfile handling#114
Lagejohn wants to merge 8 commits into
mainfrom
68-fix-stuck-lockfile

Conversation

@Lagejohn

@Lagejohn Lagejohn commented Aug 13, 2026

Copy link
Copy Markdown
Member

Instead of a lockfile containing a random hash, MMTC now creates a lockfile based on its current process ID. If it encounters an existing lockfile during initialization, it will check if the parent process of that lockfile is still running, and if not, safely removes it as a stale file from a since-cancelled run of MMTC. If the process IS still running, then it's considered an existing active instance of MMTC and the new instance will refuse to start.

This is designed to handle cases where MMTC terminated prematurely before its lockfile could be removed, preventing new runs from starting until the user manually deletes the lockfile.

Draft until manual testing is complete.

Test 1 (nominal case): Two consecutive runs are executed to verify successful acquisition and release of lockfile:
image
Result: no logged warnings about existing lockfile on second run as expected

Test 2: MMTC aborted after lock file has been acquired but before time correlation could complete; second run then reattempted:
image
Result: Second run detects and warns of stale lock file but still completes successfully.

Test 3: Second instance of MMTC started while a prior instance was still running:
image
Result: Second instance detects lockfile belonging to active process and refuses to start.

Test 4: MMTC started with intentionally corrupted/invalid lockfile already in place:
image
Result: MMTC cannot determine if the lockfile PID is running and throws as expected.

public static boolean isPidRunning(String pid) {
try {
Process process = Runtime.getRuntime().exec(
new String[]{"kill", "-0", pid} // kill -0 returns exit code 0 if process exists, doesn't send any signals
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
C Reliability Rating on New Code (required ≥ A)
B Security Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

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.

If MMTC fails at certain points after creating its lockfile, the file is never removed and will block future run attempts until it's manually deleted

2 participants