Skip to content

GH-4442: TDB2 bulk loader: report worker thread failures instead of losing them - #4443

Open
scthi wants to merge 1 commit into
apache:mainfrom
scthi:tdb2-loader-worker-failures
Open

scthi wants to merge 1 commit into
apache:mainfrom
scthi:tdb2-loader-worker-failures

Conversation

@scthi

@scthi scthi commented Nov 23, 2026

Copy link
Copy Markdown

GitHub issue resolved #4442

Pull request Description:

LoaderMain (the light, phased and parallel loader plans, tdb2.tdbloader --loader=phased|parallel|light) runs the node table and each index on worker threads. A failure on one of them never reaches the caller:

  • Indexer.stageIndex catches the exception, logs it, aborts and still releases its termination permit. If the failure comes after the producer has delivered everything, finishBulk() returns normally and the database is left with that index empty while the others are complete.
  • Once the failed indexer stops taking from its bounded queue, the producer blocks on put() for good, DataToTuples never sends its end markers, and finishBulk() hangs.
  • DataToTuples.action has the same pattern: a node-table failure is either lost or leaves the indexers waiting for end markers.
  • An Error (e.g. OutOfMemoryError) kills the thread without releasing the permit, so finishBulk() waits forever.

Changes:

  • Indexer and DataToTuples catch Throwable, record the first failure and rethrow it from finishBulk() as BulkLoaderException. Callers already handle that through finishException(), which releases LoaderMain's exclusive mode.
  • After a failure they keep the pipeline moving: an indexer drains its queue up to the end marker; DataToTuples drains its input and still sends the end markers downstream. Neither drains past an end marker it has already seen, so a failure in the final commit cannot hang either.
  • The termination permit is released in a finally block.
  • BulkProcesses.finish waits for every process even if one fails (first failure rethrown, later ones suppressed), so no worker is still running when the exclusive mode is released.
  • LoaderMain.indexPhase ends its read transaction if the replay fails.

Tests: TestLoaderMainFailures (added to TS_Loader) injects failures into an index (on the first tuple, on the last tuple, an Error) and into a DataToTuples destination, and checks BulkProcesses.finish. Against the previous code, three of them hang (stopped by a 30 s timeout), one returns normally with an index left empty, and one shows BulkProcesses.finish stopping at the first failure. With the change all pass, as do TestLoaderMainPlan and TestLoaderStdSetups.

Not addressed: a running bulk load still cannot be cancelled from outside (e.g. on a deadline). A DataLoader.abort() that interrupts the worker threads could be a follow-up.


  • Tests are included.
  • Documentation change and updates are provided for the Apache Jena website
  • Commits have been squashed to remove intermediate development commit messages.
  • Key commit messages start with the issue number (GH-xxxx)

By submitting this pull request, I acknowledge that I am making a contribution to the Apache Software Foundation under the terms and conditions of the Contributor's Agreement.


See the Apache Jena "Contributing" guide.

…d of losing them

LoaderMain runs the node table and each index on worker threads. A failure
there never reached the caller: Indexer.stageIndex and DataToTuples.action
caught the exception, logged it, aborted and still released their
termination permit, so finishBulk() either returned normally with an index
left empty or, once the failed stage stopped consuming its bounded queue,
blocked for good. An Error killed the thread without releasing the permit.

Indexer and DataToTuples now catch Throwable, record the first failure and
rethrow it from finishBulk() as BulkLoaderException. After a failure they
keep the pipeline moving: an indexer drains its queue up to the end marker,
DataToTuples drains its input and still sends the end markers downstream.
The termination permit is released in a finally block.

BulkProcesses.finish waits for every process even if one fails, so no
worker is still running when the caller releases the exclusive mode in
finishException(). LoaderMain.indexPhase ends its read transaction if the
replay fails.

TestLoaderMainFailures covers each case; against the previous code three of
them hang, one returns normally with an index left empty, and one shows
BulkProcesses.finish stopping at the first failure.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EroWQGu7H82ioAbCdFfXpP
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.

TDB2 bulk loader: an error on a loader thread is not reported; the load hangs or ends with an empty index

1 participant