[session] don't silently ignore commits
authorJulien Cristau <julien.cristau@logilab.fr>
Tue, 23 Sep 2014 13:51:12 +0200
changeset 10059 dab538127d72
parent 10058 d47c318f95b2
child 10060 08dc10ef9ab1
[session] don't silently ignore commits commits while in the precommit or postcommit phase are silently ignored. This is OK in precommit since there'll be a commit afterwards anyway; OTOH in postcommit it may surprise the developer who didn't read the documentation for postcommit operations carefully enough. Related to #4383922.
server/session.py
--- a/server/session.py	Mon Nov 24 11:49:28 2014 +0100
+++ b/server/session.py	Tue Sep 23 13:51:12 2014 +0200
@@ -1077,8 +1077,13 @@
         cstate = self.commit_state
         if cstate == 'uncommitable':
             raise QueryError('transaction must be rolled back')
-        if cstate is not None:
+        if cstate == 'precommit':
+            self.warn('calling commit in precommit makes no sense; ignoring commit')
             return
+        if cstate == 'postcommit':
+            self.critical('postcommit phase is not allowed to write to the db; ignoring commit')
+            return
+        assert cstate is None
         # on rollback, an operation should have the following state
         # information:
         # - processed by the precommit/commit event or not