Project

Profile

Help

Bug #5177

closed

Threads left unclosed if collection() is not read to completion

Added by Michael Kay over 2 years ago. Updated over 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Multithreading
Sprint/Milestone:
-
Start date:
2021-11-25
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
10, 11, trunk
Fix Committed on Branch:
11, trunk
Fixed in Maintenance Release:
Platforms:
.NET, Java

Description

In Saxon-EE, by default, the collection() function is multithreaded: a thread pool is allocated for reading the documents in the collection, so they are processed in parallel.

If the result of the collection() function is bound to a variable, and the contents of the variable are not fully processed, then the thread pool will not be properly closed down, and threads may be left in suspended animation.

Test case fn-collection-10 demonstrates the problem (though it appears to succeed in some environments and to fail in others). The code is of the form

let $c := collection($uri)
for $i in (3, 6, 8)
return $c[$i]

Internally, the collection() function produces a MultithreadedItemMappingIterator; a MemoClosure is created with this as its InputIterator, and when selected items are read by indexing into the variable, as many items are read from the InputIterator as are needed to satisfy the request. But the variable is never read to completion, so the InputIterator of the MemoClosure is never closed, and it is the close() call on a MultithreadedItemMappingIterator that causes the thread pool to be shut down

Please register to edit this issue

Also available in: Atom PDF