History | Log In     View a printable version of the current page. Get help!  
Issue Details [XML]

Key: SES-714
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Arjohn Kampman
Reporter: Nick Giles
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Sesame

ORDER BY in query can block query interruption

Created: 17/Jun/10 06:50 PM   Updated: 08/Jul/10 11:43 AM
Component/s: Query Engine
Affects Version/s: 2.3.1
Fix Version/s: 2.3.2


 Description   
If you have a query with ORDER BY, it will lock the iteration, and prevent a timeout or cancellation from working.

Test:

public void testOrderByQueriesAreInterruptable() throws Exception {
Repository repository = new SailRepository(new MemoryStore());
repository.initialize();

RepositoryConnection connection = repository.getConnection();
try {
for (int index = 0; index < 35; index++) {
connection.add(OWL.CLASS, RDFS.COMMENT, connection.getValueFactory().createBNode());
}
connection.commit();
} finally {
connection.close();
}

connection = repository.getConnection();
try {
String queryString = "SELECT * WHERE { ?s ?p ?o . ?s1 ?p1 ?o1 . ?s2 ?p2 ?o2 . ?s3 ?p3 ?o3 } ORDER BY ?s1 ?p1 ?o1";
TupleQuery query = connection.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
query.setMaxQueryTime(5);

long startTime = System.currentTimeMillis();

TupleQueryResult result = query.evaluate();
try {
result.hasNext();
fail("Query should have been interrupted");
} catch (QueryInterruptedException e) {
// Expected
long duration = System.currentTimeMillis() - startTime;

assertTrue("Query not interrupted quickly enough, should have been 5s, but was "
+ (duration / 1000) + "s", duration < 10000);
}
} finally {
connection.close();
}
}

 All   Comments   Change History      Sort Order:
Comment by Arjohn Kampman [08/Jul/10 11:43 AM]
OrderIterator.handleClose() now closes the underlying iterator (the one that is being iterated for ordering) before closing itself. This will interrupt the ordering process, preventing the long wait for the OrderIterator to be able to close itself.