Skip to content

Fix concurrent evaluation of static variables used from xquery:fork-join#2688

Open
GuntherRademacher wants to merge 1 commit into
BaseXdb:mainfrom
GuntherRademacher:#2678
Open

Fix concurrent evaluation of static variables used from xquery:fork-join#2688
GuntherRademacher wants to merge 1 commit into
BaseXdb:mainfrom
GuntherRademacher:#2678

Conversation

@GuntherRademacher
Copy link
Copy Markdown
Member

Static variables are evaluated at most once per query, involving a circular dependency check, but this was triggered incorrectly when variable values were accessed and evaluated concurrently by multiple threads started via xquery:fork-join.

The changes here

  • replace the dontEnter runtime check with query-local static-variable evaluation coordination
  • share a staticVarWaiting dependency map between parent and child query contexts
  • detect circular static-variable dependencies across:
    • same or nested query contexts
    • sibling contexts waiting on variables evaluated by each other
  • make static variable values volatile so cached results can be read before entering synchronization
  • add QueryException.Data and InputInfo.copy() so errors from failed static-variable evaluation can be reconstructed for waiting threads without sharing one mutable QueryException instance

Regression tests are added for #2678, including:

  • concurrent access to main-module and imported-module static variables
  • lazy static variables evaluated only once
  • side effects from lazy evaluation fired only once
  • circular dependencies across sibling fork-join branches
  • nested fork-join self-dependency
  • copied error reporting for concurrent circular failures

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.

1 participant