I am experiencing 100% CPU usage of postgresql after a fresh installation of discourse (v2.2.0.beta2 +120) and importing ~90k and entries from drupal.
I have traced it to the directory-item query to “create new records for users who don’t have one yet”:
The process is stuck at user 91439 of 91536 total.
Even after 48 hours of 100% CPU there is no change.
select count(*) from directory_items; remains at 91439. pg_stat_activity shows the
INSERT INTO ...() SELECT ... query in active state and 100% CPU with no end in sight.
enable user directory and re-starting discourse, works around this issue.
It does smell like a bug, but it could also be so O(N^2) complexity or something specific to the setup here.
Does anyone here have >90k users and a system where this job completes?
Any hints how I could narrow down the issue further before reporting a bug?
Thanks in advance.