Skip to content

fix(ENGKNOW-4142): delete temp table metadata folders during bucket cleanup - #160

Closed
gmagnu wants to merge 3 commits into
mainfrom
claude/engknow-4142-334f61
Closed

gmagnu wants to merge 3 commits into
mainfrom
claude/engknow-4142-334f61

Conversation

@gmagnu

@gmagnu gmagnu commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Problem

Bucketization can fail permanently for a table, with no self-recovery: every run aborts while cleaning temp data, and buckets referenced in the dictionary are never finished.

org.gorpipe.exceptions.GorResourceException: .../..<table>.temp.bucketizing.<rand>
  at FileSource.delete(FileSource.java:287)
  at BucketManager.cleanTempBucketData(BucketManager.java:623)
  at BucketManager.bucketize(BucketManager.java:183)

Root cause

  1. BucketManager.createTempTable writes a temp dictionary copy named .<table>.temp.bucketizing.<rand>.gord — one leading dot.
  2. Opening that copy as a table, TableInfoBase sets name = removeExtension(fileName) and folderPath = resolve(rootUri, "." + name). The name is already dot-prefixed, so the metadata folder becomes ..<table>.temp.bucketizing.<rand> — the double dot above.
  3. TableLifeCycleSupport creates that folder plus a history/ subdir, so it is a non-empty directory.
  4. cleanTempBucketData lists the root path and calls fileReader.delete(...) on every entry containing the temp prefix. That matches both the .gord file and the .. directory. FileSource.delete uses Files.deleteIfExists, which throws DirectoryNotEmptyException on a non-empty directory. The exception is marked .retry(), the retry handler exhausts its attempts, and bucketize aborts.

Each failed run leaves another temp directory behind, so later runs fail the same way.

Fix

Branch on entry type in cleanTempBucketData and use the recursive FileReader.deleteDirectory for folders — the same handling TableLifeCycleSupport.delete() already does.

Test

testCleaningOfOldTempDirs plants a temp metadata folder containing history/old.gord, then bucketizes. Before the fix it failed with the stack above (FileSource.delete <- cleanTempBucketData <- bucketize); after it passes. Full UTestBucketManager is green (17/17, :gortools:slowTest).

Notes

  • Developed and tested against VERSION 5.11.3; line numbers differ on later branches.
  • Deployments that already hit this keep stale ..*.temp.bucketizing.* directories on disk. Those must be removed before bucketization can succeed again — not covered by this PR.
  • GorResourceException.fromIOException only rewrites the message for FileNotFoundException, so this failure logs as a bare path with no explanation. Worth improving separately.

ENGKNOW-4142

🤖 Generated with Claude Code

gmagnu and others added 3 commits May 23, 2026 16:14
Target: 50% instruction / 40% branch coverage via two-phase approach
(command/function audit + JaCoCo gap fill) with ratchet schedule.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…leanup

Bucketization failed permanently for several clin-hg19-prd tables. The temp
dictionary copy is named ".<table>.temp.bucketizing.<rand>.gord", and opening
it as a table makes TableInfoBase derive a metadata folder of
"..<table>.temp.bucketizing.<rand>" (the name is already dot-prefixed).
TableLifeCycleSupport then creates a history/ subdir inside it, so the folder is
non-empty.

cleanTempBucketData deleted every root entry matching the temp prefix with
FileReader.delete, which is Files.deleteIfExists underneath and throws
DirectoryNotEmptyException on that folder. The exception is retried until the
handler gives up and bucketize aborts, leaving another temp folder behind on
every run.

Branch on entry type and use the recursive deleteDirectory for folders, the same
way TableLifeCycleSupport.delete() already does.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

from __future__ import annotations

import os

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.

Not addressed here: this file was never part of the intended change. The branch was cut from a commit that is not on origin/main, so unrelated work was included by mistake. This PR is closed in favour of #163, which contains only the BucketManager fix and its test.

🤖 Addressed by Claude Code

"""

from __future__ import annotations
import re, sys

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.

Not addressed here: this file was never part of the intended change. The branch was cut from a commit that is not on origin/main, so unrelated work was included by mistake. This PR is closed in favour of #163, which contains only the BucketManager fix and its test.

🤖 Addressed by Claude Code

@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown

Junit Tests - Summary

2 012 tests   - 2 756   1 916 ✅  - 2 681   10m 39s ⏱️ - 7m 45s
  208 suites  -   281      96 💤  -    75 
  208 files    -   281       0 ❌ ±    0 

Results for commit db2e7df. ± Comparison against base commit 36bd22a.

This pull request removes 2756 tests.
Gradle Test Run :gortools:integrationTest ‑ UTestAdjust
Gradle Test Run :gortools:integrationTest ‑ UTestAliasAndDefinitionReplacement
Gradle Test Run :gortools:integrationTest ‑ UTestAnalysisSink
Gradle Test Run :gortools:integrationTest ‑ UTestBGenWriteAnalysis
Gradle Test Run :gortools:integrationTest ‑ UTestBucketSplit
Gradle Test Run :gortools:integrationTest ‑ UTestColSplit
Gradle Test Run :gortools:integrationTest ‑ UTestCols2ListAnalysis
Gradle Test Run :gortools:integrationTest ‑ UTestColumnSelection
Gradle Test Run :gortools:integrationTest ‑ UTestCommandParsing
Gradle Test Run :gortools:integrationTest ‑ UTestCommandParsingAnalysisUtilities
…

@gmagnu

gmagnu commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #163. This branch was cut from a commit that is not on origin/main, so the PR carried ~13.5k lines of unrelated work and all three CI checks failed on it. #163 contains the same fix as a single commit based on origin/main.

@gmagnu gmagnu closed this Nov 1, 2026
@gmagnu
gmagnu deleted the claude/engknow-4142-334f61 branch November 1, 2026 20:42
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.

1 participant