ai-coding-minesIndexGitHub

Truncation that keeps the value from changing = infinite loop

Python and databases

Symptom

Process Killed (exit 137). Looks like out-of-memory.

Cause

while cand in seen:
    cand = f"{cand} {i}"[:99]

If the name is already 99 characters, truncation means the value never changes → loops forever. Measured memory was 36MB. The cause was a CPU-bound infinite loop.

Fix

Every piece of code that uniquifies by appending a suffix (SKU, filename, item name) has this shape.

Verification

Don't assume Killed is memory. Measure with ru_maxrss.