Problems with migration of Plone 4.3.9 to 5.0.4

"ERROR ZServerPublisher exception caught" and "ConnectionStateError" when I try to use Migration (@@plone-upgrade)

My configuration
Plone 4.3.4.1/Zope 2.13.22/Python 2.7.3 -Debian 7
Upgrade to Plone 4.3.9/Zope 2.13.24 / Python 2.7.9 - Debian 8

Module plugins on 4.3.9 are ->
Types de Contenu Dexterity 2.0.17
Support des thèmes Diazo 1.1.7
Thème Plone classique 1.3.3
Stockage de ressources statiques 1.0.5
collective.z3cform.datetimewidget 1.2.7
Enable plone.app.jquerytools support for date-time widget
plone.app.collection 1.0.13

A clean Plone 5.0.4 installation on Debian 8
A copy of Data.fs from 4.3.9 to 5.0.4
Buildout ok
Access to http://mysite:8080/ offers me to migrate my Plone instance
but migration cause a crash

2016-05-11T16:28:27 ERROR ZODB.Connection Shouldn't load state for 0x0171 when the connection is closed

2016-05-11T16:28:27 ERROR ZODB.Connection Shouldn't load state for 0x0171 when the connection is closed

2016-05-11T16:28:27 ERROR ZServerPublisher exception caught
Traceback (most recent call last):
File "/opt/plone/buildout-cache/eggs/Zope2-2.13.24-py2.7.egg/ZServer/PubCore/ZServerPublisher.py", line 31, in init
response=b)
File "/opt/plone/buildout-cache/eggs/Zope2-2.13.24-py2.7.egg/ZPublisher/Publish.py", line 455, in publish_module
environ, debug, request, response)
File "/opt/plone/buildout-cache/eggs/Zope2-2.13.24-py2.7.egg/ZPublisher/Publish.py", line 276, in publish_module_standard
if request is not None: request.close()
File "/opt/plone/buildout-cache/eggs/Zope2-2.13.24-py2.7.egg/ZPublisher/BaseRequest.py", line 220, in close
notify(EndRequestEvent(None, self))
File "/opt/plone/buildout-cache/eggs/zope.event-3.5.2-py2.7.egg/zope/event/init.py", line 31, in notify
subscriber(event)
File "/opt/plone/buildout-cache/eggs/zope.component-3.9.5-py2.7.egg/zope/component/event.py", line 24, in dispatch
zope.component.subscribers(event, None)
File "/opt/plone/buildout-cache/eggs/zope.component-3.9.5-py2.7.egg/zope/component/_api.py", line 136, in subscribers
return sitemanager.subscribers(objects, interface)
File "/opt/plone/buildout-cache/eggs/zope.component-3.9.5-py2.7.egg/zope/component/registry.py", line 321, in subscribers
return self.adapters.subscribers(objects, provided)
File "/opt/plone/buildout-cache/eggs/ZODB3-3.10.5-py2.7-linux-x86_64.egg/ZODB/Connection.py", line 857, in setstate
raise ConnectionStateError(msg)
ConnectionStateError: Shouldn't load state for 0x0171 when the connection is closed


After this crash , access to http://mysite:8080 causes the same error.
A plone restart does not fix the problem.

thank you in advance for your help

I've had that error with a memoize.ram cache that contained python objects. This looks unrelated though.

"ConnectionStateError" together with "should not load when connection is closed" indicates a misuse of a persistent object from the wrong thread. Usually, this means that a persistent object was cached in a global data structure -- i.e. at a place where different threads can access it.

Persistent objects have a (somewhat hidden) reference to the ZODB connection which has loaded the object (in the attribute "_p_jar"). ZODB connections implicitely assume that they are bound to a single thread; the thread which has opened the connection. When the thread no longer uses the connection, it closed it. The error above occurs when a thread tries to load an object from the ZODB when the object's ZODB connection is closed.

It might not be easy to find out where the error has been introduced. Errors of this kind are non-local. In your case, a persistent object seems to have been found its way into the "global component registry". This must not happen.

You may try to load the problematic persistent object (with oid "0x0171")
to find out its class and then search the source tree for its uses in an interactive debuggging session ("bin/{instance|client1} debug"). Loading an object from the ZODB (given its numeric (!) oid) looks like:
from ZODB.utils import p64 app._p_jar[p64(oid)]