Merge lp:~seif/zeitgeist/fix-598666 into lp:zeitgeist/0.1

Proposed by Seif Lotfy
Status: Merged
Merged at revision: 1622
Proposed branch: lp:~seif/zeitgeist/fix-598666
Merge into: lp:zeitgeist/0.1
Diff against target: 67 lines (+63/-0)
1 file modified
tools/cli/zeitgeist-integrity-checker.py (+63/-0)
To merge this branch: bzr merge lp:~seif/zeitgeist/fix-598666
Reviewer Review Type Date Requested Status
Mikkel Kamstrup Erlandsen Approve
Review via email: mp+39129@code.launchpad.net

Description of the change

In an attempt to fix this bug #598666 I couldn't find anything wrong with TableLookup so I added an extra check for subject_interpretation in the _insert_event method. The branch linked here is an attempt to fix this bug. Sadly I have no idea how to replicate this.

To post a comment you must log in.
Revision history for this message
Mikkel Kamstrup Erlandsen (kamstrup) wrote :

Unless there is a unit test to trigger/catch this issue I don't think it makes sense to add an extra check. In fact I think it's a bit hard to see if the patch would somehow introduce new weird corner case regressions.

So unless we understand the root cause (and have a test for it) of this bug I don't think we should merge this

review: Needs Fixing
lp:~seif/zeitgeist/fix-598666 updated
1623. By Seif Lotfy

add an integrity checker

1624. By Seif Lotfy

add documentation

1625. By Seif Lotfy

remove empty lines (clean up)

1626. By Seif Lotfy

reduce code and print more info for the integrity check

Revision history for this message
Mikkel Kamstrup Erlandsen (kamstrup) wrote :

Very nice with an integrity checker! It should help us nail this bug - and any similar bugs in the future. Approved!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'tools/cli/zeitgeist-integrity-checker.py'
2--- tools/cli/zeitgeist-integrity-checker.py 1970-01-01 00:00:00 +0000
3+++ tools/cli/zeitgeist-integrity-checker.py 2010-10-22 13:56:07 +0000
4@@ -0,0 +1,63 @@
5+#! /usr/bin/env python
6+# -.- coding: utf-8 -.-
7+
8+# Zeitgeist
9+#
10+# Copyright © 2010 Seif Lotfy <seif@lotfy.com>
11+#
12+# This program is free software: you can redistribute it and/or modify
13+# it under the terms of the GNU Lesser General Public License as published by
14+# the Free Software Foundation, either version 3 of the License, or
15+# (at your option) any later version.
16+#
17+# This program is distributed in the hope that it will be useful,
18+# but WITHOUT ANY WARRANTY; without even the implied warranty of
19+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+# GNU Lesser General Public License for more details.
21+#
22+# You should have received a copy of the GNU Lesser General Public License
23+# along with this program. If not, see <http://www.gnu.org/licenses/>.
24+
25+from zeitgeist import _config
26+_config.setup_path()
27+
28+from _zeitgeist.engine.sql import get_default_cursor
29+
30+cursor = get_default_cursor()
31+
32+# Get all ids from all tables
33+uris = [id[0] for id in cursor.execute("SELECT id FROM uri").fetchall()]
34+interpretations = [id[0] for id in cursor.execute("SELECT id FROM interpretation").fetchall()]
35+manifestations = [id[0] for id in cursor.execute("SELECT id FROM manifestation").fetchall()]
36+actors = [id[0] for id in cursor.execute("SELECT id FROM actor").fetchall()]
37+mimetypes = [id[0] for id in cursor.execute("SELECT id FROM mimetype").fetchall()]
38+texts = [id[0] for id in cursor.execute("SELECT id FROM text").fetchall()]
39+storages = [id[0] for id in cursor.execute("SELECT id FROM storage").fetchall()]
40+payloads = [id[0] for id in cursor.execute("SELECT id FROM payload").fetchall()]
41+events = [event for event in cursor.execute("SELECT * FROM event").fetchall()]
42+
43+# Check if each event field if they exist in the respected ids table
44+# if not add to the respected "failure list"
45+for event in events:
46+ if not event[2] in interpretations and event[2]:
47+ print "event %i: broken interpretation %s" %(event[0], event[2])
48+ if not event[3] in manifestations and event[3]:
49+ print "event %i: broken manifestations %s" %(event[0], event[3])
50+ if not event[4] in actors and event[4]:
51+ print "event %i: broken actor %s" %(event[0], event[4])
52+ if not event[5] in payloads and event[5]:
53+ print "event %i: broken payload %s" %(event[0], event[5])
54+ if not event[6] in uris and event[6]:
55+ print "event %i: broken subj_id %s" %(event[0], event[6])
56+ if not event[7] in interpretations and events[7]:
57+ print "event %i: broken subj_interpretation %s" %(event[0], event[7])
58+ if not event[8] in manifestations and event[8]:
59+ print "event %i: broken subj_manifestations %s" %(event[0], event[8])
60+ if not event[9] in uris and event[9]:
61+ print "event %i: broken subj_origin %s" %(event[0], event[9])
62+ if not event[10] in mimetypes and event[10]:
63+ print "event %i: broken subj_mimetype. %s" %(event[0], event[10])
64+ if not event[11] in texts and event[11]:
65+ print "event %i: broken subj_text %s" %(event[0], event[11])
66+ if not event[12] in storages and event[12]:
67+ print "event %i: broken subj_storage %s" %(event[0], event[12])

Subscribers

People subscribed via source and target branches