PR6a - fix(spec): make factory sequences unique per process - #8504
Open
LWS49 wants to merge 1 commit into
Open
Conversation
LWS49
force-pushed
the
lws49/feat-marketplace-pr6a-factories
branch
2 times, most recently
from
July 24, 2026 04:34
8e63f2b to
bb91fa7
Compare
Specs commit (use_transactional_fixtures is false), so a bare per-second timestamp collides whenever two rspec processes start within the same second, tripping unique constraints. Append the pid: two processes sharing a database run on the same host, so their pids cannot collide, and the timestamp keeps a recycled pid out of the same second.
LWS49
force-pushed
the
lws49/feat-marketplace-pr6a-factories
branch
from
July 29, 2026 12:38
bb91fa7 to
433c1b3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Spec factories built a bare per-second timestamp into their sequences. Specs run with
use_transactional_fixturesdisabled, so two rspec processes that start within the same second generate identical values and trip unique constraints. Appending the pid makes the sequences unique regardless of when a process starts: two processes that share a database run on the same host, so their pids cannot collide while both are alive, and the timestamp keeps a recycled pid out of the same second while still making leaked rows traceable to a run.This also moves the global userstamp setup into a
before(:suite)hook and resolves the stamper by the seeded admin email instead of the lowest-id human. The stamper becomes the creator (and owner course_user) of courses built in specs, and mail-sending specs deliver to that owner, so it must own a valid email. Because the suite commits without cleanup, a spec that removes the seeded admin's email leaves it removed; the next process'sdb:seedthen recreates the admin as a new user and the lowest-id human is permanently emailless. Setting the stamper at file-load time ran beforedb:seedand re-froze that stale user.Regression prevention
Covers two sequences that carried a bare timestamp: instance hosts and user email. The values only ever need to be unique, never stable or predictable, so no spec depends on their format. Exercised by every parallel rspec run.