cubicweb #3306421 add_entity_type fails with final type [waiting feedback]

e.g.:

>>> add_entity_type('Geography')
Traceback (most recent call last):
 File "<console>", line 1, in <module>
 File "/home/auc/confs/unlish/cubicweb/server/migractions.py", line 928, in cmd_add_entity_type
   self.commit()
 File "/home/auc/confs/unlish/cubicweb/server/migractions.py", line 312, in commit
   self._cnx.commit()
 File "/home/auc/confs/unlish/cubicweb/dbapi.py", line 525, in decorator
   return func(self, *args, **kwargs)
 File "/home/auc/confs/unlish/cubicweb/dbapi.py", line 751, in commit
   return self._repo.commit(self.sessionid, **self._txid())
 File "/home/auc/confs/unlish/cubicweb/server/repository.py", line 852, in commit
   return session.commit()
 File "/home/auc/confs/unlish/cubicweb/server/session.py", line 1252, in commit
   operation.handle_event('precommit_event')
 File "/home/auc/confs/unlish/cubicweb/server/hook.py", line 760, in handle_event
   getattr(self, event)()
 File "/home/auc/confs/unlish/cubicweb/hooks/syncschema.py", line 480, in precommit_event
   insert_rdef_on_subclasses(session, eschema, rschema, rdefdef, props)
 File "/home/auc/confs/unlish/cubicweb/hooks/syncschema.py", line 97, in insert_rdef_on_subclasses
   cstrtypemap = ss.cstrtype_mapping(session)
 File "/home/auc/confs/unlish/cubicweb/server/schemaserial.py", line 79, in cstrtype_mapping
   map = dict(cursor.execute('Any T, X WHERE X is CWConstraintType, X name T'))
 File "/home/auc/confs/unlish/cubicweb/server/session.py", line 1182, in execute
   rset = self._execute(self, rql, kwargs, build_descr)
 File "/home/auc/confs/unlish/cubicweb/server/querier.py", line 642, in execute
   results = plan.execute()
 File "/home/auc/confs/unlish/cubicweb/server/querier.py", line 184, in execute
   result = step.execute()
 File "/home/auc/confs/unlish/cubicweb/server/ssplanner.py", line 416, in execute
   inputmap)
 File "/home/auc/confs/unlish/cubicweb/server/sources/native.py", line 534, in syntax_tree_search
   cursor = self.doexec(session, sql, args)
 File "/home/auc/confs/unlish/cubicweb/server/sources/native.py", line 743, in doexec
   cursor.execute(str(query), args)
InternalError: current transaction is aborted, commands ignored until end of transaction block

I suspect it does too much. I have experimented with a stripped-down variant of add_entity_type and it may be good enough. add_entity_type should probably check whether the schema is final and not perform some of its heavy duties in this case.

prioritynormal
typebug
done in<not specified>
closed by<not specified>