Skip to content

processSchemaInfo is not thread-safe — concurrent Rally() instances targeting the same workspace corrupt shared _rally_schema #206

Description

@EzRyan25

When multiple Rally() instances targeting the same workspace are created concurrently (e.g. from a thread pool), processSchemaInfo in entity.py wipes _rally_schema[wksp_ref] at the very start of execution before rebuilding it. Any concurrent thread that reads the schema during that window (via typedef → getSchemaItem) receives None, which causes an AttributeError in validateAttributeNames.

Root Cause

_rally_schema is a module-level global dict. processSchemaInfo does this:

_rally_schema[wksp_ref] = {} # wipes the shared dict immediately

for ix, raw_item_info in enumerate(schema_info): # rebuilds over time (~hundreds of iterations)
item = SchemaItem(raw_item_info)
_rally_schema[wksp_ref][item.ElementName] = item
...

_rally_schema[wksp_ref]['UserStory'] = _rally_schema[wksp_ref]['HierarchicalRequirement']

The wipe and rebuild are not atomic. Any thread reading _rally_schema[wksp_ref] during the rebuild window sees either an empty dict or a partially built one. UserStory and HierarchicalRequirement are assigned at the end — they are the most likely entries to be missing during a race.

perhaps I am misunderstanding how the lib works, or I am using it wrong, either way we keep encountering these AttributeErrors: AttributeError: ("'NoneType' object has no attribute 'Attributes'",). I made a pr with a proposed fix, any help or guidance would be much appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions