Skip to content

Fix race condition in MapMerge duplicate handling under fork-join#2595

Merged
ChristianGruen merged 1 commit intoBaseXdb:mainfrom
GuntherRademacher:#2595
Feb 11, 2026
Merged

Fix race condition in MapMerge duplicate handling under fork-join#2595
ChristianGruen merged 1 commit intoBaseXdb:mainfrom
GuntherRademacher:#2595

Conversation

@GuntherRademacher
Copy link
Member

This PR fixes a concurrency issue in MapMerge when a function is supplied as the duplicates option and the query runs via xquery:fork-join. The duplicate handler was cached and captured a QueryContext, and Invoke reused a mutable HofArgs instance. Under parallel execution, this could corrupt combiner arguments and lead to sporadic errors such as:

[XPTY0004] Arithmetics not defined for xs:integer and item(): 1 * ().

Changes:

  • pass QueryContext at call time instead of caching it
  • make Invoke thread-safe by using ThreadLocal<HofArgs>
  • add regression test reproducing the failure

Related to #2479.

@ChristianGruen ChristianGruen merged commit 691873e into BaseXdb:main Feb 11, 2026
1 check passed
@ChristianGruen ChristianGruen deleted the #2595 branch February 11, 2026 14:00
GuntherRademacher added a commit to GuntherRademacher/basex that referenced this pull request Feb 11, 2026
ChristianGruen pushed a commit that referenced this pull request Feb 11, 2026
* fix race condition in `MapMerge` duplicate handling under `fork-join`

* test cleanup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants