Skip to content

Broken page cache expiration logic #89

@sattlerc

Description

@sattlerc

This is currently the logic for expiring a page:

  def expire_caches(page)
    expire_cached_summary_pages(page.web)
    pages_to_expire = [page.name] +
       WikiReference.pages_redirected_to(page.web, @will_expire) +
       WikiReference.pages_that_include(page.web, @will_expire)
    unless (page.name == @will_expire)
      pages_to_expire.concat ([@will_expire] +
        WikiReference.pages_that_link_to(page.web, @will_expire) +
        WikiReference.pages_that_reference(page.web, page.name))
    end
    pages_to_expire.uniq.each { |page_name| expire_cached_page(page.web, page_name) }
  end

But shouldn't it be as follows?

Notation for a set of pages X:

  • Write WITH_REDIRECTS(X) for the set of page names in X and redirects to some page in X.
  • Call X closed under inclusion if whenever p includes a page in WITH_REDIRECTS(X) X, then p is in X. Write INCLUSION_CLOSURE(X) for the smallest extension of X closed under inclusion. This can be computed recursively.
  • Write INCLUSION_REDIRECTS(X) for WITH_REDIRECTS(INCLUSION_CLOSURE(X)).
  • Write LINK_TO(X) for the set of pages linking to some page in X.

Then when a page p is edited:

  • For content changes: expire INCLUSION_REDIRECTS(p) INCLUSION_CLOSURE(p).
  • For wanted link status changes: expire INCLUSION_REDIRECTS(LINK_TO(WITH_REDIRECTS(p))) INCLUSION_CLOSURE(LINK_TO(WITH_REDIRECTS(p))).

There some further problems, which seem however by design and not so easily fixed:

  • None of the page/revision edit and wiki_reference query database transactions are atomic, so presumably there are race conditions with simultaneous edits.
  • Links to deleted redirects don't get expired, etc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions