Merge lp:~mvo/software-center/track-db-open into lp:software-center

Proposed by Michael Vogt
Status: Merged
Merged at revision: 2900
Proposed branch: lp:~mvo/software-center/track-db-open
Merge into: lp:software-center
Diff against target: 70 lines (+9/-6)
1 file modified
softwarecenter/db/database.py (+9/-6)
To merge this branch: bzr merge lp:~mvo/software-center/track-db-open
Reviewer Review Type Date Requested Status
Kiwinote Approve
Review via email: mp+98375@code.launchpad.net

Description of the change

Trivial branch that adds logging for Database.open() and reopen() to help finding the cause of the
bug #507836. We may need to also log the traceback in reopen(). But it might be that the error is
triggered from e.g. update-software-center-agent and in this case this branch should give us a clue.

To post a comment you must log in.
Revision history for this message
Kiwinote (kiwinote) wrote :

looks good

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'softwarecenter/db/database.py'
2--- softwarecenter/db/database.py 2012-03-15 04:30:04 +0000
3+++ softwarecenter/db/database.py 2012-03-20 09:58:20 +0000
4@@ -40,6 +40,7 @@
5 from softwarecenter.paths import XAPIAN_BASE_PATH_SOFTWARE_CENTER_AGENT
6 from gettext import gettext as _
7
8+LOG = logging.getLogger(__name__)
9
10 def parse_axi_values_file(filename="/var/lib/apt-xapian-index/values"):
11 """ parse the apt-xapian-index "values" file and provide the
12@@ -146,7 +147,6 @@
13 self._additional_databases = []
14 # the xapian values as read from /var/lib/apt-xapian-index/values
15 self._axi_values = {}
16- self._logger = logging.getLogger("softwarecenter.db")
17 # we open one db per thread, thread names are reused eventually
18 # so no memory leak
19 self._db_per_thread = {}
20@@ -176,7 +176,7 @@
21 axi = xapian.Database("/var/lib/apt-xapian-index/index")
22 xapiandb.add_database(axi)
23 except:
24- self._logger.exception("failed to add apt-xapian-index")
25+ LOG.exception("failed to add apt-xapian-index")
26 if (self._use_agent and
27 os.path.exists(XAPIAN_BASE_PATH_SOFTWARE_CENTER_AGENT)):
28 try:
29@@ -203,6 +203,8 @@
30
31 def open(self, pathname=None, use_axi=True, use_agent=True):
32 """ open the database """
33+ LOG.info("open() database: path=%s use_axi=%s "
34+ "use_agent=%s" % (pathname, use_axi, use_agent))
35 if pathname:
36 self._db_pathname = pathname
37 # clean existing DBs on open
38@@ -242,7 +244,8 @@
39 return self.xapiandb.get_metadata("db-schema-version")
40
41 def reopen(self):
42- " reopen the database "
43+ """ reopen the database """
44+ LOG.info("reopen() database")
45 self.open(use_axi=self._use_axi, use_agent=self._use_agent)
46 self.emit("reopen")
47
48@@ -283,11 +286,11 @@
49 for item in self.SEARCH_GREYLIST_STR.split(";"):
50 (search_term, n) = re.subn('\\b%s\\b' % item, '', search_term)
51 if n:
52- self._logger.debug("greylist changed search term: '%s'" %
53+ LOG.debug("greylist changed search term: '%s'" %
54 search_term)
55 # restore query if it was just greylist words
56 if search_term == '':
57- self._logger.debug("grey-list replaced all terms, restoring")
58+ LOG.debug("grey-list replaced all terms, restoring")
59 search_term = orig_search_term
60 # we have to strip the leading and trailing whitespaces to avoid having
61 # different results for e.g. 'font ' and 'font' (LP: #506419)
62@@ -463,7 +466,7 @@
63
64 If no document is found, raise a IndexError
65 """
66- #self._logger.debug("get_xapian_document app='%s' pkg='%s'" % (appname,
67+ #LOG.debug("get_xapian_document app='%s' pkg='%s'" % (appname,
68 # pkgname))
69 # first search for appname in the app-install-data namespace
70 for m in self.xapiandb.postlist("AA" + appname):

Subscribers

People subscribed via source and target branches