0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-06 13:08:40 +08:00
discourse/lib/tasks
Mark VanLandingham c85593eda8
PERF: Add fast nested reply stats preparation (#41870)
## Problem

Nested reply statistics currently start backfilling only after nested
replies are enabled. At the default 100 topics every five minutes, that
is 28,800 topics per day—about 174 days for a site with five million
topics. Large sites therefore have to expose the feature before its
historical stats are ready.

## Solution

Add a backend-only `nested_replies:prepare_stats` rake task. For each
site, it:

- enables the existing realtime stats callbacks while the nested-replies
UI remains disabled;
- captures the current regular-topic high-water mark;
- enqueues low-priority, keyset-paginated batches which immediately
enqueue the next batch instead of waiting five minutes;
- reuses the existing per-topic backfill SQL; and
- isolates an individual failed topic into its own job, where normal
Sidekiq retries apply, so later topics can continue.

The task leaves the hidden maintenance flag enabled, so replies created,
deleted, or reparented after preparation begins keep the same stats
current before nested replies are enabled. On multisite it prepares
every database by default; `RAILS_DB` scopes it to one database.

The existing scheduled backfill keeps its original feature gate, topic
selection, batch schedule, and calculations. This adds no UI,
migrations, stats version, readiness marker, durable cursor setting,
lock, or watchdog.

Run it with:

```sh
RAILS_ENV=production bin/rake nested_replies:prepare_stats
```

Completion is logged with the captured high-water topic ID. Re-running
the task is safe because it uses the existing idempotent upsert
behavior.

Tests cover disabled-mode preparation, bounded continuation and
high-water behavior, isolated retries, rake-task enqueueing,
preservation of the old scheduler gate, and realtime maintenance while
the UI is disabled.
2026-07-21 10:45:53 -05:00
..
add_topic_to_quotes.rake
admin.rake DEV: Enable Style/RedundantParentheses rubocop rule (#40095) 2026-05-19 15:48:09 +02:00
annotate.rake DEV: Run independent CI checks in parallel (#41640) 2026-07-13 10:55:28 +08:00
annotate_rb.rake
api.rake
api_docs.rake
assets.rake DEV: Rename EmberCli to EmberAssets (#40938) 2026-06-16 12:56:56 +02:00
autospec.rake
avatars.rake
backfill.thor
categories.rake
cdn.rake DEV: Enable Rails/FilePath rubocop rule (#40097) 2026-05-19 19:07:54 +02:00
compatibility.rake
db.rake DEV: Show exception error class and message in db:seed (#41615) 2026-07-13 05:46:45 +08:00
db_structure.rake DEV: Run independent CI checks in parallel (#41640) 2026-07-13 10:55:28 +08:00
destroy.rake
dev.rake DEV: Enable Style/RedundantParentheses rubocop rule (#40095) 2026-05-19 15:48:09 +02:00
docker.rake DEV: Enable Rails/FilePath rubocop rule (#40097) 2026-05-19 19:07:54 +02:00
documentation.rake DEV: Enable Rails/FilePath rubocop rule (#40097) 2026-05-19 19:07:54 +02:00
emails.rake DEV: Enable Style/RedundantBegin rubocop rule (#40096) 2026-05-19 18:44:54 +02:00
export.rake
groups.rake
hashtags.rake
i18n.rake
images.rake DEV: Enable Rails/FilePath rubocop rule (#40097) 2026-05-19 19:07:54 +02:00
import.rake FIX: Update renamed anonymous auto group (#40664) 2026-06-09 06:19:48 +00:00
incoming_emails.rake
javascript.rake UX: Explain invalid automatic membership email domains (#41233) 2026-07-02 16:52:16 +02:00
list_email_templates_strings.rake
log.rake
maxminddb.rake
migrate_advanced_search_banner_to_welcome_banner.rake
migrate_discourse_gifs_to_core.rake DEV: remove enable gifs upcoming change metadata (#41798) 2026-07-20 12:30:00 +04:00
nested_replies.rake PERF: Add fast nested reply stats preparation (#41870) 2026-07-21 10:45:53 -05:00
plugin.rake FEATURE: Show theme d-compat/* refs in admin UI (#40649) 2026-06-17 22:13:45 +01:00
populate.rake FEATURE: Add top countries and top referrers cards to the admin dashboard (#40215) 2026-05-22 12:59:16 +08:00
populate.thor DEV: Fix assigned but unused variable Prism warnings (#39436) 2026-04-22 12:42:14 +02:00
posts.rake DEV: Enable Style/RedundantBegin rubocop rule (#40096) 2026-05-19 18:44:54 +02:00
profile.rake
qunit.rake
redis.rake
release.rake DEV: Fixup release task logic (#39612) 2026-05-13 10:59:41 +01:00
release_note.rake
reviewables.rake
revisions.rake
rspec.rake
s3.rake FIX: Include rollup file hash in plugin entrypoint filenames (#40853) 2026-06-15 09:24:28 +01:00
scheduler.rake
search.rake
site.rake FEATURE: extract text from document uploads for LLM prompts (#39634) 2026-05-05 08:16:23 +10:00
site_settings.rake FIX: type: objects uploads should be stored as IDs (#40178) 2026-05-21 13:45:27 -03:00
smoke_test.rake DEV: Enable Rails/FilePath rubocop rule (#40097) 2026-05-19 19:07:54 +02:00
svg_icons.rake DEV: Enable Rails/FilePath rubocop rule (#40097) 2026-05-19 19:07:54 +02:00
svg_sprites.rake
tags.rake
themes.rake DEV: add typescript support for core, themes and plugins (#41478) 2026-07-08 12:57:18 +01:00
topic_localizations.rake
topics.rake
turbo.rake
typepad.thor DEV: Enable Style/RedundantParentheses rubocop rule (#40095) 2026-05-19 15:48:09 +02:00
uploads.rake DEV: Enable Rails/FilePath rubocop rule (#40097) 2026-05-19 19:07:54 +02:00
user_api_key.rake FEATURE: User API key device authorization flow (#40189) 2026-06-10 16:09:44 -04:00
users.rake DEV: Enable Style/RedundantBegin rubocop rule (#40096) 2026-05-19 18:44:54 +02:00