Skip to content
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

Rolling back a failing transaction through the HTTPRepositoryConnection results in transaction not found #725

Closed
nikolavp opened this issue Jan 17, 2017 · 2 comments
Assignees
Labels
🐞 bug issue is a bug
Milestone

Comments

@nikolavp
Copy link
Contributor

nikolavp commented Jan 17, 2017

If for some reason the transaction failed inside the database (sail implementation side), there is no way to close or rollback the transaction properly by the client.

Example code on the client side:

try {
    HTTPRepositoryConnection connection = ....
    connection.add(statement); // something that will cause a transaction failure
    connection.commit();
} catch (Exception ex) {
    connection.rollback(); // this causes the missing transaction message
} finally {
    connection.close(); // this also causes it because the transaction is active and the connection wants to rollback.
}

Here is a full stacktrace on the server

[ERROR] 2017-01-17 18:02:49,783 [repositories/graphdb_standard_test_1_1484668930169 | o.e.r.h.s.ProtocolExceptionResolver] Error while handling request
org.eclipse.rdf4j.repository.RepositoryException: transaction with id 08f1e560-4308-402c-9414-62d64e158d0e not registered.
	at org.eclipse.rdf4j.http.server.repository.transaction.ActiveTransactionRegistry.getTransaction(ActiveTransactionRegistry.java:139)
	at org.eclipse.rdf4j.http.server.repository.transaction.TransactionController.handleRequestInternal(TransactionController.java:113)
	at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:146)
	at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:50)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966)
	at org.springframework.web.servlet.FrameworkServlet.doDelete(FrameworkServlet.java:890)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:654)
	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
	at com.github.ziplet.filter.compression.CompressingFilter.doFilter(CompressingFilter.java:300)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:522)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1095)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:745)

and on the client side

org.eclipse.rdf4j.repository.RepositoryException: org.eclipse.rdf4j.repository.RepositoryException: transaction with id 0e5cb052-0eef-4fc8-86e2-27f8d2c41ea9 not registered.

	at org.eclipse.rdf4j.repository.http.HTTPRepositoryConnection.rollback(HTTPRepositoryConnection.java:357)
	at org.eclipse.rdf4j.repository.http.HTTPRepositoryConnection.close(HTTPRepositoryConnection.java:373)
	at com.ontotext.test.functional.base.AbstractInconsistencyInference.testStatementWithChecks(AbstractInconsistencyInference.java:54)
	at com.ontotext.test.functional.base.AbstractInconsistencyInference.testWithAsymmetricProperty(AbstractInconsistencyInference.java:129)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:48)
	at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:48)
	at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:48)
	at com.ontotext.test.Repeat$1.evaluate(Repeat.java:40)
	at org.junit.rules.RunRules.evaluate(RunRules.java:20)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:237)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Caused by: org.eclipse.rdf4j.repository.RepositoryException: transaction with id 0e5cb052-0eef-4fc8-86e2-27f8d2c41ea9 not registered.
	at org.eclipse.rdf4j.http.client.SparqlSession.execute(SparqlSession.java:1132)
	at org.eclipse.rdf4j.http.client.SesameSession.rollbackTransaction(SesameSession.java:553)
	at org.eclipse.rdf4j.repository.http.HTTPRepositoryConnection.rollback(HTTPRepositoryConnection.java:353)
	... 35 more

this affects rdf4j 2.1.5 and is caused by 5880ad6 where the transaction is deregistered in a finally on commit. This is not correct because, if the transaction failed, it should stay in the registry.

@abrokenjester
Copy link
Contributor

This is indeed a bug, but I should point out not really critical from a data consistency POV: if a transaction gets deregistered, it gets closed, which in turn triggers rollback if necessary. So the user-invoked rollback fails (which is ugly and a bug), but the transaction has been properly rolled back and closed, internally.

@abrokenjester abrokenjester added the 🐞 bug issue is a bug label Jan 17, 2017
@ansell
Copy link
Contributor

ansell commented Jan 18, 2017

Scratch that, I was put off by the connection.add line comment. The commit you refer to is the line after, in commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug issue is a bug
Projects
None yet
Development

No branches or pull requests

3 participants