Skip to content

Commit

Permalink
Link._submit: Pass is_self to constructor.
Browse files Browse the repository at this point in the history
This was causing deletes to be issued to the `LinksByUrl` column
family for all self posts. Self posts that were left in an
inconsistent state due to dropped double commits ended up reading this
row which had several hundred thousand tombstones, which lead to
Cassandra performance issues.
  • Loading branch information
kjoconnor authored and bsimpson63 committed Sep 10, 2015
1 parent b1fe5d9 commit 7482750
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions r2/r2/models/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,18 +212,25 @@ def _submit(cls, is_self, title, content, author, sr, ip,
spam=False, sendreplies=True):
from r2.models import admintools

l = cls(_ups=1,
title=title,
url=TEMPORARY_SELFPOST_URL if is_self else content,
_spam=spam,
author_id=author._id,
sendreplies=sendreplies,
sr_id=sr._id,
lang=sr.lang,
ip=ip,
comment_tree_version=cls._choose_comment_tree_version())
l = cls(
_ups=1,
title=title,
url=TEMPORARY_SELFPOST_URL if is_self else content,
_spam=spam,
author_id=author._id,
sendreplies=sendreplies,
sr_id=sr._id,
lang=sr.lang,
ip=ip,
comment_tree_version=cls._choose_comment_tree_version(),
is_self=is_self,
)

l._commit()
# Note: this does not provide atomicity, so for self posts when
# a request dies after the previous line but before `set_type`,
# you will have a link whose URL is literally 'self', and whose
# selftext will not be set.
l.set_type(is_self, content)

LinksByAccount.add_link(author, l)
Expand Down

0 comments on commit 7482750

Please sign in to comment.