<div class="gmail_quote">On Sat, Jan 30, 2010 at 6:56 AM, Shane Hathaway <span dir="ltr">&lt;<a href="mailto:shane@hathawaymix.org">shane@hathawaymix.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div></div><div class="h5">Rudá Porto Filgueiras wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
How can I repair or verify a RelStorage database?<br>
I´m using MySQL Adapter, there is any script like fsrecover.py<br>
<br>
Follow the failure when RelStorage try to load some objects:<br>
<br>
2010-01-30T04:25:14 ERROR ZODB.Connection Couldn&#39;t load state for 0x04ef0f59<br>
Traceback (most recent call last):<br>
  File &quot;/usr/local/zope-agecom/plone/eggs/ZODB3-3.8.4_polling-py2.4-linux-x86_64.egg/ZODB/Connection.py&quot;, line 847, in setstate<br>
    self._setstate(obj)<br>
  File &quot;/usr/local/zope-agecom/plone/eggs/ZODB3-3.8.4_polling-py2.4-linux-x86_64.egg/ZODB/Connection.py&quot;, line 888, in _setstate<br>
    p, serial = self._storage.load(obj._p_oid, self._version)<br>
  File &quot;/usr/local/zope-agecom/plone/eggs/RelStorage-1.4.0b1-py2.4.egg/relstorage/storage.py&quot;, line 432, in load<br>
    raise POSKeyError(oid)<br>
POSKeyError: 0x04ef0f59<br>
</blockquote>
<br></div></div>
To diagnose this, I would:<br>
<br>
- Examine the logs in detail.  There should be a log entry giving details about that specific POSKeyError.<br></blockquote><div><br><br>Follow error from november 2009 (there are some repeated (five) errors like that on the date/time).<br>
<br>550308-2009-11-28T05:31:51 ERROR ZODB.Connection Couldn&#39;t load state for 0x03ebd4<br>550309-Traceback (most recent call last):<br>550310-  File &quot;/usr/local/zope/agecom-virtual/eggs/ZODB3-3.7.3_polling-py2.4-linux-x86_64.egg/ZODB/Connection.py&quot;, line 797, in setstate<br>
550311-    self._setstate(obj)<br>550312-  File &quot;/usr/local/zope/agecom-virtual/eggs/ZODB3-3.7.3_polling-py2.4-linux-x86_64.egg/ZODB/Connection.py&quot;, line 855, in _setstate<br>550313-    self._reader.setGhostState(obj, p)<br>
550314-  File &quot;/usr/local/zope/agecom-virtual/eggs/ZODB3-3.7.3_polling-py2.4-linux-x86_64.egg/ZODB/serialize.py&quot;, line 604, in setGhostState<br>550315-    state = self.getState(pickle)<br>550316-  File &quot;/usr/local/zope/agecom-virtual/eggs/ZODB3-3.7.3_polling-py2.4-linux-x86_64.egg/ZODB/serialize.py&quot;, line 597, in getState<br>
550317-    return unpickler.load()<br>550318-  File &quot;/usr/local/zope/agecom-virtual/eggs/ZODB3-3.7.3_polling-py2.4-linux-x86_64.egg/ZODB/serialize.py&quot;, line 471, in _persistent_load<br>550319-    return self.load_oid(reference)<br>
550320-  File &quot;/usr/local/zope/agecom-virtual/eggs/ZODB3-3.7.3_polling-py2.4-linux-x86_64.egg/ZODB/serialize.py&quot;, line 537, in load_oid<br>550321-    return self._conn.get(oid)<br>550322-  File &quot;/usr/local/zope/agecom-virtual/eggs/ZODB3-3.7.3_polling-py2.4-linux-x86_64.egg/ZODB/Connection.py&quot;, line 225, in get<br>
550323-    p, serial = self._storage.load(oid, self._version)<br>550324-  File &quot;/usr/local/zope/agecom-virtual/eggs/ZODB3-3.7.3_polling-py2.4-linux-x86_64.egg/ZODB/Connection.py&quot;, line 1196, in load<br>550325-    return self._storage.load(oid, self._base_version)<br>
550326-  File &quot;/usr/local/zope/agecom-virtual/eggs/ZODB3-3.7.3_polling-py2.4-linux-x86_64.egg/ZEO/ClientStorage.py&quot;, line 727, in load<br>550327-    return self.loadEx(oid, version)[:2]<br>550328-  File &quot;/usr/local/zope/agecom-virtual/eggs/ZODB3-3.7.3_polling-py2.4-linux-x86_64.egg/ZEO/ClientStorage.py&quot;, line 750, in loadEx<br>
550329-    data, tid, ver = self._server.loadEx(oid, version)<br>550330-  File &quot;/usr/local/zope/agecom-virtual/eggs/ZODB3-3.7.3_polling-py2.4-linux-x86_64.egg/ZEO/ServerStub.py&quot;, line 196, in loadEx<br>550331-    return self.rpc.call(&quot;loadEx&quot;, oid, version)<br>
550332-  File &quot;/usr/local/zope/agecom-virtual/eggs/ZODB3-3.7.3_polling-py2.4-linux-x86_64.egg/ZEO/zrpc/connection.py&quot;, line 650, in call<br>550333-    raise inst # error raised by server<br>550334:POSKeyError: 0x06294e<br>
<br>This errros is today errors, there are repeated (10) errors like that:<br><br>835744:2010-01-30T09:26:47 WARNING relstorage POSKeyError on oid 1793877: no tid found; Current transaction is 253262639700997905; Recent object tids: []<br>
835745-------<br>835746-2010-01-30T09:26:47 ERROR ZODB.Connection Couldn&#39;t load state for 0x1b5f55<br>835747-Traceback (most recent call last):<br>835748-  File &quot;/usr/local/zope/agecom-virtual/eggs/ZODB3-3.8.4_polling-py2.4-linux-x86_64.egg/ZODB/Connection.py&quot;, line 847, in setstate<br>
835749-    self._setstate(obj)<br>835750-  File &quot;/usr/local/zope/agecom-virtual/eggs/ZODB3-3.8.4_polling-py2.4-linux-x86_64.egg/ZODB/Connection.py&quot;, line 888, in _setstate<br>835751-    p, serial = self._storage.load(obj._p_oid, self._version)<br>
835752-  File &quot;/usr/local/zope/agecom-virtual/eggs/RelStorage-1.4.0b1-py2.4.egg/relstorage/storage.py&quot;, line 432, in load<br>835753:    raise POSKeyError(oid)<br>835754:POSKeyError: 0x1b5f55<br>835756-2010-01-30T09:26:48 INFO Archetypes ESC[00mESC[01;32m/usr/local/zope/agecom-virtual/parts/plone/Archetypes/UIDCatalog.py[106]:getObject<br>
835757-ESC[00mUIDCatalogBrains getObject raised an error:<br>835758- Traceback (most recent call last):<br>835759-<br>835760-  File &quot;/usr/local/zope/agecom-virtual/parts/plone/Archetypes/UIDCatalog.py&quot;, line 87, in getObject<br>
835761-    path = self.getPath()<br>835762-<br>835763-  File &quot;/usr/local/zope/agecom-virtual/parts/zope2/lib/python/Products/ZCatalog/CatalogBrains.py&quot;, line 33, in getPath<br>835764-    return self.aq_parent.getpath(self.data_record_id_)<br>
835765-<br>835766-  File &quot;/usr/local/zope/agecom-virtual/parts/zope2/lib/python/Products/ZCatalog/ZCatalog.py&quot;, line 608, in getpath<br>835767-    return self._catalog.paths[rid]<br>835768-<br>835769-  File &quot;/usr/local/zope/agecom-virtual/eggs/ZODB3-3.8.4_polling-py2.4-linux-x86_64.egg/ZODB/Connection.py&quot;, line 847, in setstate<br>
835770-    self._setstate(obj)<br>835771-<br>835772-  File &quot;/usr/local/zope/agecom-virtual/eggs/ZODB3-3.8.4_polling-py2.4-linux-x86_64.egg/ZODB/Connection.py&quot;, line 888, in _setstate<br>835773-    p, serial = self._storage.load(obj._p_oid, self._version)<br>
835774-<br>835775-  File &quot;/usr/local/zope/agecom-virtual/eggs/RelStorage-1.4.0b1-py2.4.egg/relstorage/storage.py&quot;, line 432, in load<br>835776:    raise POSKeyError(oid)<br>835777-<br>835778:POSKeyError: 0x1b5f55<br>
<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
- Shut down MySQL and back up the database as-is.<br>
<br></blockquote><div>I discover the problem after restore database on another MySQL/Zope server and try to do Plone migration 2.5 -&gt; 3.2.<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

- Run the MySQL database verification and repair tools.  It&#39;s possible that the object you need is there, but MySQL can&#39;t find it due to corrupted indexes or similar.<br>
<br></blockquote><div><br>I will do that, but it must afert 02:00 am. :-)<br>Did you think PostgreSQL is more resistent to such failures than MySQL?<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

- Run a pack in dry-run mode, which will fill the object_refs table so I can find out exactly what object(s) refer to that OID (note that 0x04ef0f59 is 82775897 in decimal).<br>
<br></blockquote><div><br>Yes, I know that, there is a function to do this conversion on ZODB package.<br>Is <br>&gt;&gt;&gt; from ZODB.utils import U64<br>&gt;&gt;&gt; U64(&#39;0x1b5f55&#39;)<br>3492595808898266421L<br>
<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
- Use both SQL and &quot;zopectl debug&quot; to examine the breakage.<br></blockquote><div><br>On SQL I need to inspect current_object, object_ref and object_state to find these &quot;ghost&quot; objects and who is trying to load then?<br>
 <br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
Running a pack in dry-run mode performs verification without actually deleting anything.  There is no fsrecover-like script, but I could be convinced to create one if the need arises.<br><font color="#888888">
<br></font></blockquote><div><br>I don&#39;t know how dificult is, but I&#39;m sure this will be a high value for now and the future. :-)<br>For me it can be something like zodbconvert (moving from the same or another Storage type) but doing these corrections when it find transactions or lod object failure.<br>
<br>I try to use ZODB convert to moving from MySQL to FileStorage, but it generates a failure, but I do that to discover the exactly transaction and date time that generates other failure.<br><br>After that I correct the problem by creating  a &quot;stub dict&quot; pickle object_state to be able to delete the &quot;father&quot; content becouse before that if I try to list the folder contents it generates POSKeyError exception.<br>
<br>I expect not need to do this again, but know that happen again, could be a server problem, and I have backup.<br>But how I can restore old database and apply all good objects created after the corrupted transaction?<br>
<br>Anyway, thanks for your support.<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><font color="#888888">
Shane<br>
</font></blockquote></div><br clear="all"><br>-- <br>Rudá Porto Filgueiras<br><a href="http://python-blog.blogspot.com">http://python-blog.blogspot.com</a><br><a href="http://twitter.com/rudaporto">http://twitter.com/rudaporto</a><br>