Project

Profile

Help

Bug #3979

closed

Synchronization of xsl:message

Added by Michael Kay over 5 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Multithreading
Sprint/Milestone:
-
Start date:
2018-10-23
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
9.8, 9.9
Fix Committed on Branch:
9.8, 9.9
Fixed in Maintenance Release:
Platforms:

Description

Because all xsl:message output within a transformation is sent to the same MessageEmitter, and because the MessageEmitter will generally not be thread-safe, xsl:message synchronizes itself on the message emitter so that a transformation can only be executing one xsl:message instruction at any one time. This is only a problem, of course, if xsl:message is used within multi-threading constructs such as xsl;result-document or a multi-threading xsl:for-each instruction.

The synchronization causes a number of problems identified in thread https://saxonica.plan.io/boards/3/topics/7336

  • It can cause contention and hence negate any benefits of multi-threading

  • Holding a synchronization lock while executing potentially long-running user-written code is intrinsically bad for performance and creates a risk of deadlock.

  • One can probably create code that will inevitably deadlock, for example by using a multi-threading construct within the body of the xsl:message instruction.

Possible solutions include (a) buffering the content of the xsl:message output in memory, and holding the synchronization lock only while writing the output to the MessageEmitter, and (b) disabling multi-threading constructs such as xsl:for-each with the saxon:threads attribute while evaluating xsl:message.

Note: perhaps surprisingly, xsl:message does not set temporary output state, so it is possible to execute xsl:result-document while executing xsl:message.

Please register to edit this issue

Also available in: Atom PDF