Opened 97 minutes ago

Closed 71 minutes ago

Last modified 54 minutes ago

#37002 closed Bug (duplicate)

Off-by-one error in parallel test worker index validation

Reported by: Shashank Kushwaha Owned by:
Component: Testing framework Version: 6.0
Severity: Normal Keywords: parallel testing, off-by-one, worker-id
Cc: Shashank Kushwaha Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

In django/test/runner.py, the validation of _worker_id uses:

if _worker_id > len(db_aliases):

However, valid worker IDs should range from 0 to len(db_aliases) - 1.

For example, if len(db_aliases) = 3, valid IDs are 0, 1, and 2. The current condition allows _worker_id == 3, which is invalid.

This appears to be an off-by-one error and should likely use:

if _worker_id >= len(db_aliases):

This was observed while reviewing PR #20971.

Change History (3)

comment:1 by Shashank Kushwaha, 97 minutes ago

i'd like to work on this , if accepted.

comment:2 by Shashank Kushwaha, 71 minutes ago

Resolution: fixed
Status: newclosed

It looks like this issue has been addressed in PR #20971 by adding validation for _worker_id >= len(db_aliases) before usage.

I’m marking this as fixed. Happy to close if no further action is needed.

comment:3 by Jacob Walls, 54 minutes ago

Resolution: fixedduplicate

Duplicate of #27734

Note: See TracTickets for help on using tickets.
Back to Top