discourse/spec
Alan Guo Xiang Tan 7c321d3aad
PERF: Update `Group#user_count` counter cache outside DB transaction (#19256)
While load testing our user creation code path in production, we
identified that executing the DB statement to update the `Group#user_count` column within a
transaction is creating a bottleneck for us. This is because the
creation of a user and addition of the user to the relevant groups are
done in a transaction. When we execute the DB statement to update
`Group#user_count` for the relevant group, a row level lock is held
until the transaction completes. This row level lock acts like a global
lock when the server is creating users that will be added to the same
group in quick succession.

Instead of updating the counter cache within a transaction which the
default ActiveRecord `counter_cache` option does, we simply update the
counter cache outside of the committing transaction.

Co-authored-by: Rafael dos Santos Silva <xfalcox@gmail.com>

Co-authored-by: Rafael dos Santos Silva <xfalcox@gmail.com>
2022-11-30 11:52:08 -03:00
..
fabricators PERF: stop downloading images from post processor and lean on uploads 2022-11-25 12:40:31 +11:00
fixtures PERF: stop downloading images from post processor and lean on uploads 2022-11-25 12:40:31 +11:00
helpers Meta topic: https://meta.discourse.org/t/meta-theme-color-is-not-respecting-current-color-scheme/239815 (#18832) 2022-11-07 10:06:26 +03:00
import_export DEV: Add a rake task to export/import translation overrides (#18487) 2022-10-05 15:22:16 -04:00
initializers Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
integration FEATURE: Track API and user API requests (#19186) 2022-11-29 13:07:42 +02:00
integrity DEV: Use proper wording for contexts in specs 2022-08-04 11:05:02 +02:00
jobs PERF: Update `Group#user_count` counter cache outside DB transaction (#19256) 2022-11-30 11:52:08 -03:00
lib FIX: Allow svg in oneboxer in certain cases (#19253) 2022-11-30 12:42:15 +10:00
mailers SECURITY: Filter tags in user notifications for visibility (#19239) 2022-11-29 10:35:41 -06:00
models PERF: Update `Group#user_count` counter cache outside DB transaction (#19256) 2022-11-30 11:52:08 -03:00
multisite DEV: Fix mocha deprecations (#18828) 2022-11-02 10:47:59 +01:00
requests SECURITY: Hide notifications for inaccessible topics (#19208) 2022-11-28 10:41:57 +10:00
script/import_scripts DEV: Remove remaining hardcoded ids (#18735) 2022-10-25 15:29:09 +08:00
serializers FIX: do not lock account if backup codes are available (#18982) 2022-11-11 13:00:06 +11:00
services FIX: Push category hashtag slug match to top (#19174) 2022-11-25 15:28:49 +10:00
support FEATURE: Generic hashtag autocomplete lookup and markdown cooking (#18937) 2022-11-21 08:37:06 +10:00
system FEATURE: Generic hashtag autocomplete lookup and markdown cooking (#18937) 2022-11-21 08:37:06 +10:00
tasks FIX: Allow attr updates of over-size-limit uploads (#18986) 2022-11-11 17:56:11 +01:00
views Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
rails_helper.rb FEATURE: Generic hashtag autocomplete lookup and markdown cooking (#18937) 2022-11-21 08:37:06 +10:00
regenerate_swagger_docs DEV: Add API docs for uploads and API doc watcher (#15387) 2021-12-23 08:40:15 +10:00
swagger_helper.rb DEV: Update rubocop (#18754) 2022-10-26 09:05:15 +08:00