Stop making unnecessary db calls in rebuild_kb() task

RESOLVED FIXED in 2012Q4

Status

support.mozilla.org
Knowledge Base Software
P3
normal
RESOLVED FIXED
6 years ago
5 years ago

People

(Reporter: rrosario, Assigned: rrosario)

Tracking

unspecified
2012Q4

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: u=dev c=wiki p=0 s=2012.19)

(Assignee)

Description

6 years ago
We call rebuild_kb() on cron every 6 hours. It goes through all the wiki documents that have a current_revision set and updates it's html:

    document.html = document.current_revision.content_parsed
    document.save()


This is wasteful as most of the time there content has not changed but we are always making a full database call. There are two optimizations we can do here:

1- First compare the values and, if they are the same, move on.
2- Do an update() instead of a save(). That way we are only sending back the html field. This kills a tiny race condition and avoids sending unchanged data back to the db for update. This would also skip post_save signals. If we want this to trigger a reindex of the document, we'll have to call it directly or something. It currently isn't triggering the reindex.
(Assignee)

Comment 1

6 years ago
(In reply to Ricky Rosario [:rrosario, :r1cky] from comment #0)
> If we want this to trigger a reindex of the document, we'll have to call it
> directly or something. It currently isn't triggering the reindex.

See bug 797038
(Assignee)

Comment 3

6 years ago
Landed and deployed:

https://github.com/mozilla/kitsune/commit/4a66185a082672f6070b7b4d9378462e0d367781
Status: NEW → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → FIXED
Adding s= sprint information to whiteboard.
Whiteboard: u=dev c=wiki p=0 → u=dev c=wiki p=0 s=2012.19
You need to log in before you can comment on or make changes to this bug.