Skip to content

GH-5347 make the ShaclSail more robust during shutdown() #5348

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 22 commits into
base: main
Choose a base branch
from

Conversation

hmottestad
Copy link
Contributor

GitHub issue resolved: #5347

Briefly describe the changes proposed in this PR:


PR Author Checklist (see the contributor guidelines for more details):

  • my pull request is self-contained
  • I've added tests for the changes I made
  • I've applied code formatting (you can use mvn process-resources to format from the command line)
  • I've squashed my commits where necessary
  • every commit message starts with the issue number (GH-xxxx) followed by a meaningful description of the change

@hmottestad hmottestad requested a review from Copilot June 10, 2025 16:09
Copilot

This comment was marked as outdated.

@hmottestad hmottestad requested a review from Copilot June 10, 2025 16:21
Copilot

This comment was marked as outdated.

@hmottestad
Copy link
Contributor Author

TODO

  • Test for serial validation
  • Test that actually fails SHACL validation
  • Test for bulk validation

@hmottestad hmottestad requested a review from Copilot June 11, 2025 08:39
Copilot

This comment was marked as outdated.

@hmottestad hmottestad force-pushed the GH-5347-shacl-sail-shutdown-close-everything branch from 856e399 to f65873b Compare June 27, 2025 09:21
@hmottestad hmottestad requested a review from Copilot June 27, 2025 09:23
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Enhance SHACL Sail shutdown robustness by adding interruption checks, tracking and cancelling in-progress validation tasks, and improving resource cleanup.

  • Added thread-interruption guards across plan nodes and iterators to abort validation on shutdown
  • Tracked and cancelled in-flight validation futures and shape validation containers in ShaclSailConnection
  • Improved shutdown logic in ShaclSail, AbstractSailConnection, and AbstractSail to avoid resource leaks and hanging threads

Reviewed Changes

Copilot reviewed 27 out of 27 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
ShutdownDuringValidationTest.java New parameterized tests for concurrent shutdown during validation
PrepareCommitTest.java New tests for shutdown timing around prepare and commit
ConnectionsGroup.java Catch UncheckedExecutionException when loading cache entries
ValidationResultIterator.java Interrupt check in tuple iteration loop
ValidationTuple.java Interrupt check in comparison methods
UnionNode.java Early exit on interrupt and closed state
Sort.java Added interrupt/closed checks and iterator cleanup
Select.java Added interrupt close handling, cleaned up bindingSet
SparqlQueryParserCache.java Unified exception catch, added logging for parse errors
ShapeValidationContainer.java Track and force-close active ValidationResultIterator
ShaclValidator.java Interruption check before building lazy report
ShaclSailConnection.java Track and cancel validation futures; shutdown guards
ShaclSail.java Executor shutdown improvements and isShutdown check
DelegatingSailSource.java Null delegate guard
AbstractSailConnection.java Adjusted close sequence and active-iteration tracking
AbstractSail.java Interrupt and close active connections on shutdown
LookAheadIteration.java Log and swallow stray NoSuchElementException in hasNext
FilterIteration.java Interrupt guard in findNextElement
Comments suppressed due to low confidence (3)

core/sail/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/ShutdownDuringValidationTest.java:59

  • The error message references benchmarkFiles/datagovbe-valid.ttl but the resource path is complexBenchmark/datagovbe-valid.ttl; please correct the path in the message.
			throw new RuntimeException("Could not load file: benchmarkFiles/datagovbe-valid.ttl", e);

core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ast/SparqlQueryParserCache.java:58

  • The logger identifier is not defined in this class, leading to a compile error. You should add a private static final Logger logger = LoggerFactory.getLogger(SparqlQueryParserCache.class); declaration or use an existing logger.
				logger.error("Error parsing query: \n{}", query, cause);

Comment on lines +19 to +24
Thread.currentThread().interrupt();
}

public InterruptedSailException() {
super();
Thread.currentThread().interrupt();
Copy link
Preview

Copilot AI Jun 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The exception constructor is modifying the thread's interrupt flag as a side effect, which is unexpected. It's better to let callers decide when to interrupt the thread.

Suggested change
Thread.currentThread().interrupt();
}
public InterruptedSailException() {
super();
Thread.currentThread().interrupt();
}
public InterruptedSailException() {
super();

Copilot uses AI. Check for mistakes.

Comment on lines 173 to 179
// try {
return bindingSet.hasNext();
// } catch (NoSuchElementException e) {
// // This can happen if the connection is closed while we are iterating.
// // In that case, we just return false.
// return false;
// }
Copy link
Preview

Copilot AI Jun 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Commented-out code remains in localHasNext. Please remove dead code or restore proper exception handling.

Suggested change
// try {
return bindingSet.hasNext();
// } catch (NoSuchElementException e) {
// // This can happen if the connection is closed while we are iterating.
// // In that case, we just return false.
// return false;
// }
try {
return bindingSet.hasNext();
} catch (NoSuchElementException e) {
// This can happen if the connection is closed while we are iterating.
// In that case, we just return false.
return false;
}

Copilot uses AI. Check for mistakes.

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.

ShaclSail should interrupt all validation threads and close all resources when shutdown() is called
1 participant