Comment #14 on issue 3022 by rb-site manage index does not work

I think I have solved part of the problem :D

In our company, we have a 'commit-reader'-script running on the codereview server, which monitors any svn-commits. For each such commit, a draft review-request (or update review, depending on the commit-message) is created. During initialization of this script, it tries to synchronize svn and Review Board, by issuing many webapi-requests onto the Review Board server in order to find out which svn-revisions have already been added to Review Board.

However, each webapi http-request creates a new record in the django_sessions-table. This gave problems, as the hard-disk quickly ran out of memory. In order to fix this, I 'patched' the Sessions-middleware, by creating the following file (about 2 years ago):

# ==========================

from django.contrib.sessions.middleware import SessionMiddleware

def dontsave(must_create=True):

class PatchedSessionMiddleware(SessionMiddleware):
    def process_request(self, request):
        super(PatchedSessionMiddleware, self).process_request(request)

# Because the commit_reader performs lots of requests to /api/... urls,
        # for each request a session-id would be stored in the database.
        # This would grow the database in size very quickly.
        # This check prevents that.
        if request.path_info[0:5] == '/api/':
   = dontsave

# First import the original MIDDLEWARE_CLASSES-list
from reviewboard.settings import MIDDLEWARE_CLASSES

# Now overwrite the SessionMiddleware-class with our patched version
cls = SessionMiddleware.__module__ + '.' + SessionMiddleware.__name__
idx = MIDDLEWARE_CLASSES.index(cls)
MIDDLEWARE_CLASSES[idx] = __name__ + '.' + PatchedSessionMiddleware.__name__


And finally I added the following line to the file:

from settings_local_sessionmiddleware import MIDDLEWARE_CLASSES

Apparently, importing this file was the cause of the current problem (perhaps due to a circular dependency?). By removing this line, it looks like everything works again.

Indexing now works fine, as well as the 'rb-site manage shell' (although issuing 'print settings.__file__' still complains about the 'Settings' object not having this attribute).

The only issue that remains is the Sessions-middleware. If I inspect my database, I see:

                      relation                       |  size
 public.django_session_pkey                          | 1785 MB
 public.django_session_expire_date                   | 1030 MB
 public.django_session                               | 699 MB
 pg_toast.pg_toast_16671                             | 203 MB
 public.diffviewer_filediff                          | 70 MB
 pg_toast.pg_toast_119386                            | 51 MB
 public.diffviewer_filediffdata                      | 19 MB
 public.reviews_reviewrequest                        | 3776 kB
 public.diffviewer_filediff_diff_hash_id             | 3040 kB
 public.diffviewer_filediff_diff_hash_id_like        | 3040 kB
 public.reviews_comment                              | 2752 kB
 pg_toast.pg_toast_16671_index                       | 2600 kB
 public.diffviewer_filediff_diffset_id               | 2088 kB
 public.changedescs_changedescription                | 1912 kB
 public.diffviewer_filediff_parent_diff_hash_id_like | 1848 kB
 public.diffviewer_filediff_parent_diff_hash_id      | 1840 kB
 public.diffviewer_filediffdata_pkey                 | 1776 kB
 public.diffviewer_filediff_pkey                     | 1728 kB
 public.reviews_review                               | 1424 kB
 public.diffviewer_diffset                           | 1136 kB

As can be seen, the session-data uses quite some space. Furthermore, I believe I already emptied the django_session table back then, when I created the patched middleware-class.

Is this a known problem and is there a better way to solve this?

You received this message because this project is configured to send all issue notifications to this address.
You may adjust your notification preferences at:

You received this message because you are subscribed to the Google Groups 
"reviewboard-issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
To post to this group, send email to
Visit this group at
For more options, visit

Reply via email to