Skip to content

Race condition in XMLSchema initialisation #315

@vladimir-mencl-eresearch

Description

Hi,

When using a map task in a pipeline, which triggers multithreading, I get occasional error when the XMLSchema gets initialised.

This happens only sometimes, so I assume this is a race condition possibly in lxml.

When it happens, I get:

Traceback (most recent call last):
  File "/opt/mdsign/pyff-venv/lib/python3.11/site-packages/pyff/utils.py", line 233, in schema
    thread_data.schema = etree.XMLSchema(st)
                         ^^^^^^^^^^^^^^^^^^^
  File "src/lxml/xmlschema.pxi", line 90, in lxml.etree.XMLSchema.__init__
lxml.etree.XMLSchemaParseError: Element '{http://www.w3.org/2001/XMLSchema}element', attribute 'ref': The QName value '{http://www.w3.org/2005/08/addressing}EndpointReference' does not resolve to a(n) element declaration., line 179
ERROR:pyff.utils:<string>:179:0:ERROR:SCHEMASP:SCHEMAP_SRC_RESOLVE: Element '{http://www.w3.org/2001/XMLSchema}element', attribute 'ref': The QName value '{http://www.w3.org/2005/08/addressing}EndpointReference' does not resolve to a(n) element declaration.
<string>:368:0:ERROR:SCHEMASP:SCHEMAP_SRC_RESOLVE: element decl. '{http://docs.oasis-open.org/wsfed/federation/200706}ReferenceEPR', attribute 'type': The QName value '{http://www.w3.org/2005/08/addressing}EndpointReferenceType' does not resolve to a(n) type definition.
<string>:436:0:ERROR:SCHEMASP:SCHEMAP_SRC_RESOLVE: element decl. '{http://docs.oasis-open.org/wsfed/federation/200706}RequireReferenceToken', attribute 'type': The QName value '{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}TokenAssertionType' does not resolve to a(n) type definition.
<string>:447:0:ERROR:SCHEMASP:SCHEMAP_SRC_RESOLVE: element decl. '{http://docs.oasis-open.org/wsfed/federation/200706}WebBinding', attribute 'type': The QName value '{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}NestedPolicyType' does not resolve to a(n) type definition.
<string>:448:0:ERROR:SCHEMASP:SCHEMAP_SRC_RESOLVE: element decl. '{http://docs.oasis-open.org/wsfed/federation/200706}AuthenticationToken', attribute 'type': The QName value '{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}NestedPolicyType' does not resolve to a(n) type definition.

The exact point where it happens in the schema file varies, but it is alway `QNAME ... does not resolve to a(n) element declaration.'

In utils.py, I see the XMLSchema object is created separately in each thread, with the thread_local_lock lock acquired to avoid concurrent use. This apepars to be consistent with LXML documentation. While I can see this does not prevent other concurrent LXML use, given the XMLSchema is parsed with a parser instance local to the thread, this should all be within what LXML permits.

Has this been reported or observed anywhere else?

Many thanks in advance for any assistance with this.

Cheers,
Vlad

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions