Skip to:
Content

bbPress.org

Opened 4 weeks ago

Closed 4 weeks ago

Last modified 3 weeks ago

#3678 closed defect (bug) (fixed)

Counts: prevent lost concurrent metadata deltas

Reported by: johnjamesjacoby Owned by: johnjamesjacoby
Priority: normal Milestone: 2.6.16
Component: General - Performance Version:
Severity: normal Keywords:
Cc:

Description

bbPress originally recalculated counts from content, but moved to stored deltas to keep forum submissions responsive. #1799 introduced the forum, topic, reply, and voice bump functions in r3826 and moved normal topic and reply operations from recount queries to deltas in r6036. r5309 added user contribution deltas for #1694, retaining raw recount fallbacks when metadata was missing. The benchmark in ticket:1799#comment:22 reduced average new-reply time from about 18.54 seconds to 5.39 seconds, with similar improvements for topic creation and moderation actions. Counts were allowed to be temporarily imperfect, with repair tools providing eventual correction. That performance tradeoff should remain the default.

The current bump helpers read the post or user metadata value, apply a difference in PHP, and then write the new value. Concurrent submissions can read the same old value and one write can overwrite the other, silently losing a delta until a repair runs. This is narrower than ordinary temporary count inconsistency.

Investigate atomic delta updates that preserve submission performance without adding full recount queries to the normal posting lifecycle. Preserve existing filters, non-negative clamping, metadata cache invalidation, multisite user-option keys, and public function lifecycles. Include a posting-path performance comparison and cover concurrent or deterministically interleaved updates, missing metadata, supported topic and reply statuses, and aggregate forum counts.

This affects both trunk and the 2.6 maintenance branch.

Change History (10)

#1 @johnjamesjacoby
4 weeks ago

In 7453:

Counts: improve repair and subforum integrity.

Count public, private, and hidden subforums from the post hierarchy, and synchronize parent counts when forums change visibility, parent, post type, or are permanently deleted. Keep child relationship metadata aligned when WordPress reparents forums.

Correct count repair queries to target bbPress post types, honor filtered statuses, exclude anonymous authors, preserve unrelated metadata, repair empty user counts, clear metadata caches after direct database writes, and detect database failures from wpdb return values.

In trunk, for 2.7.

Props netweb, GDragoN.
Fixes #2649.
Fixes #2664.
See #2533, #2586, #3678.

#2 @johnjamesjacoby
4 weeks ago

In 7454:

Counts: improve repair and subforum integrity.

Count public, private, and hidden subforums from the post hierarchy, and synchronize parent counts when forums change visibility, parent, post type, or are permanently deleted. Keep child relationship metadata aligned when WordPress reparents forums.

Correct count repair queries to target bbPress post types, honor filtered statuses, exclude anonymous authors, preserve unrelated metadata, repair empty user counts, clear metadata caches after direct database writes, and detect database failures from wpdb return values.

Merges r7453 to 2.6.

In 2.6, for 2.6.16.

See #2533, #2586, #2649, #2664, #3678.

#3 @johnjamesjacoby
4 weeks ago

  • Owner set to johnjamesjacoby
  • Resolution → fixed
  • Status new → closed

In 7467:

Counts: synchronize metadata across concurrent writes.

Introduce bbp_bump_count_meta() to update existing numeric metadata with bounded compare-and-swap retries while preserving WordPress metadata filters, actions, sanitization, and cache invalidation. Apply atomic differences to forum, topic, reply, ancestor, and user contribution counts.

Reconcile counts, engagements, and voices across status transitions, permanent deletion, author changes and reassignment, moderator move/merge/split operations, and repair recounts. Correct recursive forum totals and reply visibility, and preserve term-backed favorites and subscriptions during engagement rebuilds.

Document the count-hook compatibility changes and new helper arguments, and add regression coverage for single-site and multisite workflows.

In trunk, for 2.7.

Props alex-ye.
Fixes #2233.
Fixes #3678.

#4 @johnjamesjacoby
4 weeks ago

In 7468:

Counts: synchronize metadata across concurrent writes.

Introduce bbp_bump_count_meta() to update existing numeric metadata with bounded compare-and-swap retries while preserving WordPress metadata filters, actions, sanitization, and cache invalidation. Apply atomic differences to forum, topic, reply, ancestor, and user contribution counts.

Reconcile counts, engagements, and voices across status transitions, permanent deletion, author changes and reassignment, moderator move/merge/split operations, and repair recounts. Correct recursive forum totals and reply visibility, and preserve term-backed favorites and subscriptions during engagement rebuilds.

Document the count-hook compatibility changes and new helper arguments, and add regression coverage for single-site and multisite workflows.

Merges r7467 to 2.6.

In 2.6, for 2.6.16.

See #2233, #3678.

#5 @johnjamesjacoby
4 weeks ago

In 7471:

Documentation: expand count compatibility notes.

Document count-hook timing for creation and moderation, custom-status integration, atomic metadata retry semantics, subforum query filters, and selective repair guidance for existing sites.

In trunk, for 2.7.

See #3678.

#6 @johnjamesjacoby
4 weeks ago

In 7472:

Documentation: expand count compatibility notes.

Document count-hook timing for creation and moderation, custom-status integration, atomic metadata retry semantics, subforum query filters, and selective repair guidance for existing sites.

Merges r7471 to 2.6.

In 2.6, for 2.6.16.

See #3678.

#7 @johnjamesjacoby
4 weeks ago

In 7475:

Counts: avoid forum-wide reply recounts.

Apply a topic's stored public reply count as an atomic forum difference when the topic enters or leaves the public status set. Add a short-circuit filter for integrations that replace the complete persisted transition count operation.

Add coverage for custom hidden statuses, moderation cascades, and the replacement lifecycle.

In trunk, for 2.7.

See #3678.

#8 @johnjamesjacoby
4 weeks ago

In 7478:

Counts: avoid forum-wide reply recounts.

Apply a topic's stored public reply count as an atomic forum difference when the topic enters or leaves the public status set. Add a short-circuit filter for integrations that replace the complete persisted transition count operation.

Add coverage for custom hidden statuses, moderation cascades, and the replacement lifecycle.

Merges [7475] to 2.6.

In 2.6, for 2.6.16.

See #3678.

#9 @johnjamesjacoby
3 weeks ago

In 7526:

Users: Preserve reply status when moderating users.

Process a user's replies before their topics when marking the user as spam or ham. Topic status helpers can transition child replies, so deterministic parent-last processing preserves each reply's stored status and keeps counts synchronized across database result orders.

In trunk, for 2.7.

See #3678.

#10 @johnjamesjacoby
3 weeks ago

In 7527:

Users: Preserve reply status when moderating users.

Process a user's replies before their topics when marking the user as spam or ham. Topic status helpers can transition child replies, so deterministic parent-last processing preserves each reply's stored status and keeps counts synchronized across database result orders.

This is a backport of [7526] to the 2.6 branch.

In branches/2.6, for 2.6.16.

See #3678.

Note: See TracTickets for help on using tickets.