Python's PYTHONHASHSEED caused random migration order, not a framework bug
A developer spent two days debugging a migration generator that produced identical SQL statements in a different order on each run. The root cause was Python's default per-process hash randomisation, which affects set iteration order for strings, bytes, and datetime keys. A dependency resolver in the codebase used set.pop() to walk module names, and since set ordering follows salted hash table layout, the sequence changed with every new process. The bug was invisible inside a single REPL session, which was the key clue that pointed to a per-process rather than a per-call variable. The fix requires replacing set-based iteration with an explicitly ordered structure such as a sorted list wherever deterministic sequencing matters.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in