diff --git a/hive/indexer/cached_post.py b/hive/indexer/cached_post.py index 53a6ad08d..d98b1fac0 100644 --- a/hive/indexer/cached_post.py +++ b/hive/indexer/cached_post.py @@ -352,26 +352,22 @@ def _bump_last_id(cls, next_id): if next_id <= last_id: return - if next_id - last_id > 2: + gap = next_id - last_id - 1 + if gap: cls._ensure_safe_gap(last_id, next_id) - if next_id - last_id > 4: - # gap of 2 is common due to deletions. report on larger gaps. - log.warning("skipping post ids %d -> %d", last_id, next_id) + log.warning("skipped %d posts %d -> %d", gap, last_id, next_id) cls._last_id = next_id @classmethod def _ensure_safe_gap(cls, last_id, next_id): """Paranoid check of important operating assumption.""" - sql = """ - SELECT COUNT(*) FROM hive_posts - WHERE id BETWEEN :x1 AND :x2 AND is_deleted = '0' - """ + sql = """SELECT COUNT(*) FROM hive_posts + WHERE id BETWEEN :x1 AND :x2 AND is_deleted = '0'""" missing_posts = DB.query_one(sql, x1=(last_id + 1), x2=(next_id - 1)) - if not missing_posts: - return - raise Exception("found large cache gap: %d --> %d (%d)" - % (last_id, next_id, missing_posts)) + if missing_posts: + raise Exception("found cache gap: %d --> %d (%d)" + % (last_id, next_id, missing_posts)) @classmethod def _sql(cls, pid, post, level=None):