ConnectionStateError 的可能原因是什么?

What are the possible causes of a ConnectionStateError?

我在使用 Plone 4.3.8 站点时遇到 ConnectionStateError 问题。

我找不到发生这种情况的原因。我在很多不同的情况下都能理解,我会 post 一些回溯来告诉你我的意思。

正在加载 portlet 页面:

2016-08-01T11:38:15 ERROR Zope.SiteErrorLog 1470044295.40.967961803473 https://mysite.it/home-page/two-columns
Traceback (innermost last):
  Module ZPublisher.Publish, line 127, in publish
  Module ZPublisher.BaseRequest, line 607, in traverse
  Module Products.PluggableAuthService.PluggableAuthService, line 244, in validate
  Module Products.PluggableAuthService.PluggableAuthService, line 652, in _extractUserIds
  Module Products.WebServerAuth.plugin, line 131, in authenticateCredentials
  Module ZODB.Connection, line 857, in setstate
ConnectionStateError: Shouldn't load state for 0x184af9 when the connection is closed

正在加载随机文件夹:

2016-08-01T13:04:17 ERROR Zope.SiteErrorLog 1470049457.660.586381895694 https://mysite.it/some/path/folder_tabular_view
Traceback (innermost last):
  Module ZPublisher.Publish, line 138, in publish
  Module ZPublisher.mapply, line 77, in mapply
  Module ZPublisher.Publish, line 48, in call_object
  Module Shared.DC.Scripts.Bindings, line 322, in __call__
  Module Shared.DC.Scripts.Bindings, line 359, in _bindAndExec
  Module Products.CMFCore.FSPageTemplate, line 237, in _exec
  Module Products.CMFCore.FSPageTemplate, line 177, in pt_render
  Module Products.PageTemplates.PageTemplate, line 87, in pt_render
  Module zope.pagetemplate.pagetemplate, line 132, in pt_render
  Module five.pt.engine, line 93, in __call__
  Module z3c.pt.pagetemplate, line 149, in render
  Module chameleon.zpt.template, line 261, in render
  Module chameleon.template, line 191, in render
  Module chameleon.template, line 171, in render
  Module 3d823c0177a7023e7fe9a133289da7b0.py, line 853, in render
  Module 153d4bce30f6569f92b3bf03cb6d6485.py, line 1060, in render_master
  Module z3c.pt.expressions, line 58, in render_content_provider
  Module zope.viewlet.manager, line 112, in update
  Module zope.viewlet.manager, line 118, in _updateViewlets
  Module plone.app.layout.links.viewlets, line 122, in update
  Module Products.CMFPlone.browser.syndication.utils, line 47, in context_enabled
  Module zope.component.hookable, line 33, in __call__
  Module zope.component.hooks, line 104, in adapter_hook
  Module Products.CMFPlone.browser.syndication.settings, line 23, in __init__
  Module zope.annotation.attribute, line 44, in get
  Module ZODB.Connection, line 857, in setstate
ConnectionStateError: Shouldn't load state for 0x05f568 when the connection is closed

 - Expression: "provider:plone.htmlhead.links"
 - Filename:   ... me/skins/my_plonetheme_custom_templates/main_template.pt
 - Location:   (line 32: col 37)
 - Source:     ... replace="structure provider:plone.htmlhead.links" />
                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 - Arguments:  repeat: {...} (0)
               template: <ImplicitAcquisitionWrapper folder_tabular_view at 0x7fb4e901b820>
               modules: <instance - at 0x7fb509ba5878>
               here: <ImplicitAcquisitionWrapper i-commisione-consiliare at 0x7fb4e901ba50>
               user: <ImplicitAcquisitionWrapper - at 0x7fb4e901baf0>
               nothing: <NoneType - at 0x937be0>
               container: <ImplicitAcquisitionWrapper i-commisione-consiliare at 0x7fb4e901ba50>
               default: <object - at 0x7fb510fbc520>
               request: <instance - at 0x7fb4ddaafe60>
               wrapped_repeat: <SafeMapping - at 0x7fb4df604520>
               traverse_subpath: <list - at 0x7fb4dfba61b8>
               loop: {...} (0)
               context: <ImplicitAcquisitionWrapper i-commisione-consiliare at 0x7fb4e901ba50>
               translate: <function translate at 0x7fb4de933848>
               root: <ImplicitAcquisitionWrapper Zope at 0x7fb4e8b5a960>
               options: {...} (1)
               target_language: <NoneType - at 0x937be0>

正在加载视图:

2016-08-02T22:53:57 ERROR plone.app.viewletmanager rendering of plone.belowcontenttitle in plone.belowcontenttitle.documentbyline fails: Shouldn't load state for 0x1e3183 when the connection is closed

 - Expression: "context/Rights"
 - Filename:   ... 4-py2.7.egg/plone/app/layout/viewlets/document_byline.pt
 - Location:   (line 79: col 33)
 - Source:     ... rights tal:define="rights context/Rights"
                                             ^^^^^^^^^^^^^^
 - Arguments:  repeat: {...} (0)
               template: <ViewPageTemplateFile - at 0x7fb501617990>
               views: <ViewMapper - at 0x7fb4deb88410>
               modules: <instance - at 0x7fb509ba5878>
               args: <tuple - at 0x7fb51109e050>
               here: <ImplicitAcquisitionWrapper notizie at 0x7fb4ea918aa0>
               user: <ImplicitAcquisitionWrapper - at 0x7fb4e8734960>
               nothing: <NoneType - at 0x937be0>
               container: <ImplicitAcquisitionWrapper notizie at 0x7fb4ea918aa0>
               request: <instance - at 0x7fb4f13d37e8>
               wrapped_repeat: <SafeMapping - at 0x7fb4d7edd7e0>
               traverse_subpath: <list - at 0x7fb4de297dd0>
               default: <object - at 0x7fb510fbc520>
               loop: {...} (0)
               context: <ImplicitAcquisitionWrapper notizie at 0x7fb4ea918aa0>
               view: <DocumentBylineViewlet plone.belowcontenttitle.documentbyline at 0x7fb4deb888d0>
               translate: <function translate at 0x7fb4dc1ce320>
               root: <ImplicitAcquisitionWrapper Zope at 0x7fb4dfcd4370>
               options: {...} (0)
               target_language: <NoneType - at 0x937be0>
Traceback (most recent call last):
  File "/opt/cache/buildout/eggs/plone.app.viewletmanager-2.0.9-py2.7.egg/plone/app/viewletmanager/manager.py", line 110, in render
    html.append(viewlet.render())
  File "/opt/cache/buildout/eggs/plone.app.layout-2.3.14-py2.7.egg/plone/app/layout/viewlets/common.py", line 50, in render
    return self.index()
  File "/opt/cache/buildout/eggs/Zope2-2.13.23-py2.7.egg/Products/Five/browser/pagetemplatefile.py", line 125, in __call__
    return self.im_func(im_self, *args, **kw)
  File "/opt/cache/buildout/eggs/Zope2-2.13.23-py2.7.egg/Products/Five/browser/pagetemplatefile.py", line 59, in __call__
    sourceAnnotations=getattr(debug_flags, 'sourceAnnotations', 0),
  File "/opt/cache/buildout/eggs/zope.pagetemplate-3.6.3-py2.7.egg/zope/pagetemplate/pagetemplate.py", line 132, in pt_render
    strictinsert=0, sourceAnnotations=sourceAnnotations
  File "/opt/cache/buildout/eggs/five.pt-2.2.3-py2.7.egg/five/pt/engine.py", line 93, in __call__
    return self.template.render(**kwargs)
  File "/opt/cache/buildout/eggs/z3c.pt-2.2.3-py2.7.egg/z3c/pt/pagetemplate.py", line 149, in render
    return base_renderer(**context)
  File "/opt/cache/buildout/eggs/Chameleon-2.24-py2.7.egg/chameleon/zpt/template.py", line 261, in render
    return super(PageTemplate, self).render(**vars)
  File "/opt/cache/buildout/eggs/Chameleon-2.24-py2.7.egg/chameleon/template.py", line 191, in render
    raise_with_traceback(exc, tb)
  File "/opt/cache/buildout/eggs/Chameleon-2.24-py2.7.egg/chameleon/template.py", line 171, in render
    self._render(stream, econtext, rcontext)
  File "c3f6907c0e1b52a047b37fee3042155a.py", line 699, in render
  File "/opt/cache/buildout/eggs/five.pt-2.2.3-py2.7.egg/five/pt/expressions.py", line 161, in __call__
    return base()
  File "/opt/cache/buildout/eggs/Products.Archetypes-1.9.10-py2.7.egg/Products/Archetypes/ClassGen.py", line 56, in generatedAccessor
    return schema[name].get(self, **kw)
  File "/opt/cache/buildout/eggs/wicked-1.1.12-py2.7.egg/wicked/fieldevent/__init__.py", line 29, in render
    notify(renderer)
  File "/opt/cache/buildout/eggs/zope.event-3.5.2-py2.7.egg/zope/event/__init__.py", line 31, in notify
    subscriber(event)
  File "/opt/cache/buildout/eggs/zope.component-3.9.5-py2.7.egg/zope/component/event.py", line 24, in dispatch
    zope.component.subscribers(event, None)
  File "/opt/cache/buildout/eggs/zope.component-3.9.5-py2.7.egg/zope/component/_api.py", line 136, in subscribers
    return sitemanager.subscribers(objects, interface)
  File "/opt/cache/buildout/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/cache/buildout/eggs/zope.interface-3.6.7-py2.7-linux-x86_64.egg/zope/interface/adapter.py", line 585, in subscribers
    subscription(*objects)
  File "/opt/cache/buildout/eggs/wicked-1.1.12-py2.7.egg/wicked/fieldevent/__init__.py", line 16, in notifyFieldEvent
    event.value = getMultiAdapter((field, event), IFieldValue)
  File "/opt/cache/buildout/eggs/zope.component-3.9.5-py2.7.egg/zope/component/_api.py", line 107, in getMultiAdapter
    adapter = queryMultiAdapter(objects, interface, name, context=context)
  File "/opt/cache/buildout/eggs/zope.component-3.9.5-py2.7.egg/zope/component/_api.py", line 120, in queryMultiAdapter
    return sitemanager.queryMultiAdapter(objects, interface, name, default)
  File "/opt/cache/buildout/eggs/zope.component-3.9.5-py2.7.egg/zope/component/registry.py", line 238, in queryMultiAdapter
    objects, interface, name, default)
  File "/opt/cache/buildout/eggs/zope.interface-3.6.7-py2.7-linux-x86_64.egg/zope/interface/adapter.py", line 532, in queryMultiAdapter
    result = factory(*objects)
  File "/opt/cache/buildout/eggs/wicked-1.1.12-py2.7.egg/wicked/fieldevent/meta.py", line 78, in field_value
    return _get(field, event.instance, **event.kwargs)
  File "/opt/cache/buildout/eggs/Products.Archetypes-1.9.10-py2.7.egg/Products/Archetypes/Field.py", line 1502, in get
    if not shasattr(value, 'transform'):  # oldBaseUnits have no transform
  File "/opt/cache/buildout/eggs/Products.Archetypes-1.9.10-py2.7.egg/Products/Archetypes/utils.py", line 734, in shasattr
    return getattr(obj, attr, _marker) is not _marker
  File "/opt/cache/buildout/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 0x1e3183 when the connection is closed

 - Expression: "context/Rights"
 - Filename:   ... 4-py2.7.egg/plone/app/layout/viewlets/document_byline.pt
 - Location:   (line 79: col 33)
 - Source:     ... rights tal:define="rights context/Rights"
                                             ^^^^^^^^^^^^^^
 - Arguments:  repeat: {...} (0)
               template: <ViewPageTemplateFile - at 0x7fb501617990>
               views: <ViewMapper - at 0x7fb4deb88410>
               modules: <instance - at 0x7fb509ba5878>
               args: <tuple - at 0x7fb51109e050>
               here: <ImplicitAcquisitionWrapper notizie at 0x7fb4ea918aa0>
               user: <ImplicitAcquisitionWrapper - at 0x7fb4e8734960>
               nothing: <NoneType - at 0x937be0>
               container: <ImplicitAcquisitionWrapper notizie at 0x7fb4ea918aa0>
               request: <instance - at 0x7fb4f13d37e8>
               wrapped_repeat: <SafeMapping - at 0x7fb4d7edd7e0>
               traverse_subpath: <list - at 0x7fb4de297dd0>
               default: <object - at 0x7fb510fbc520>
               loop: {...} (0)
               context: <ImplicitAcquisitionWrapper notizie at 0x7fb4ea918aa0>
               view: <DocumentBylineViewlet plone.belowcontenttitle.documentbyline at 0x7fb4deb888d0>
               translate: <function translate at 0x7fb4dc1ce320>
               root: <ImplicitAcquisitionWrapper Zope at 0x7fb4dfcd4370>
               options: {...} (0)
               target_language: <NoneType - at 0x937be0>

我可以举出很多不同的例子。 我似乎找不到原因,我可能遗漏了一些有关可能导致问题的信息。

我会提供任何需要的额外信息,请随时询问 :) 谢谢!

ConnectionStateError可以生成不止一种问题。

有时您只需要重新启动客户端,但我相信您已经尝试过了。

也有可能是您的 zeo 服务器出了问题(您有一个,对吧?)。检查其日志并评估是否值得重新启动。

更常见的情况:您正在使用来自 plone.memoize 的 RAMCache,但您正在缓存持久对象。 别这样。