Userlist not working

If you open the hamburger-menu, and select “Users”, the list shows up and everything ist is working.
If you change the period to “all” (in german: “Gesamt”), the loading animation is spinning for ever.

v1.7.0.beta11 +105
URL: https://www.[myforum].com/users?period=all

Logs:

NoMethodError (undefined method `time_read' for nil:NilClass)
/var/www/discourse/app/serializers/directory_item_serializer.rb:14:in `time_read'

[code] /var/www/discourse/app/serializers/directory_item_serializer.rb:14:in `time_read' (eval):4:in `_fast_attributes' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/active_model_serializers-0.8.3/lib/active_model/serializer.rb:467:in `rescue in attributes' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/active_model_serializers-0.8.3/lib/active_model/serializer.rb:455:in `attributes' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/active_model_serializers-0.8.3/lib/active_model/serializer.rb:479:in `_serializable_hash' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/active_model_serializers-0.8.3/lib/active_model/serializer.rb:361:in `serializable_hash' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/active_model_serializers-0.8.3/lib/active_model/array_serializer.rb:89:in `block in _serializable_array' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/active_model_serializers-0.8.3/lib/active_model/array_serializer.rb:79:in `map' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/active_model_serializers-0.8.3/lib/active_model/array_serializer.rb:79:in `_serializable_array' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/active_model_serializers-0.8.3/lib/active_model/array_serializer.rb:73:in `serializable_array' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/active_model_serializers-0.8.3/lib/active_model/array_serializer.rb:53:in `as_json' /var/www/discourse/app/controllers/application_controller.rb:294:in `serialize_data' /var/www/discourse/app/controllers/directory_items_controller.rb:66:in `index' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/actionpack-4.2.7.1/lib/action_controller/metal/implicit_render.rb:4:in `send_action' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/actionpack-4.2.7.1/lib/abstract_controller/base.rb:198:in `process_action' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/actionpack-4.2.7.1/lib/action_controller/metal/rendering.rb:10:in `process_action' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/actionpack-4.2.7.1/lib/abstract_controller/callbacks.rb:20:in `block in process_action' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:117:in `call' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:555:in `block (2 levels) in compile' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:505:in `call' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:92:in `__run_callbacks__' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:778:in `_run_process_action_callbacks' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:81:in `run_callbacks' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/actionpack-4.2.7.1/lib/abstract_controller/callbacks.rb:19:in `process_action' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/actionpack-4.2.7.1/lib/action_controller/metal/rescue.rb:29:in `process_action' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/actionpack-4.2.7.1/lib/action_controller/metal/instrumentation.rb:32:in `block in process_action' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/notifications.rb:164:in `block in instrument' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/notifications/instrumenter.rb:20:in `instrument' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/notifications.rb:164:in `instrument' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/actionpack-4.2.7.1/lib/action_controller/metal/instrumentation.rb:30:in `process_action' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/actionpack-4.2.7.1/lib/action_controller/metal/params_wrapper.rb:250:in `process_action' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/railties/controller_runtime.rb:18:in `process_action' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/actionpack-4.2.7.1/lib/abstract_controller/base.rb:137:in `process' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/actionview-4.2.7.1/lib/action_view/rendering.rb:30:in `process' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/rack-mini-profiler-0.10.1/lib/mini_profiler/profiling_methods.rb:102:in `block in profile_method' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/actionpack-4.2.7.1/lib/action_controller/metal.rb:196:in `dispatch' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/actionpack-4.2.7.1/lib/action_controller/metal/rack_delegation.rb:13:in `dispatch' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/actionpack-4.2.7.1/lib/action_controller/metal.rb:237:in `block in action' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/actionpack-4.2.7.1/lib/action_dispatch/routing/route_set.rb:74:in `dispatch' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/actionpack-4.2.7.1/lib/action_dispatch/routing/route_set.rb:43:in `serve' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/actionpack-4.2.7.1/lib/action_dispatch/journey/router.rb:43:in `block in serve' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/actionpack-4.2.7.1/lib/action_dispatch/journey/router.rb:30:in `each' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/actionpack-4.2.7.1/lib/action_dispatch/journey/router.rb:30:in `serve' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/actionpack-4.2.7.1/lib/action_dispatch/routing/route_set.rb:817:in `call' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/rack-protection-1.5.3/lib/rack/protection/frame_options.rb:31:in `call' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/omniauth-1.3.1/lib/omniauth/strategy.rb:186:in `call!' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/omniauth-1.3.1/lib/omniauth/strategy.rb:164:in `call' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/omniauth-1.3.1/lib/omniauth/strategy.rb:186:in `call!' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/omniauth-1.3.1/lib/omniauth/strategy.rb:164:in `call' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/omniauth-1.3.1/lib/omniauth/strategy.rb:186:in `call!' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/omniauth-1.3.1/lib/omniauth/strategy.rb:164:in `call' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/omniauth-1.3.1/lib/omniauth/strategy.rb:186:in `call!' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/omniauth-1.3.1/lib/omniauth/strategy.rb:164:in `call' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/omniauth-1.3.1/lib/omniauth/strategy.rb:186:in `call!' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/omniauth-1.3.1/lib/omniauth/strategy.rb:164:in `call' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/omniauth-1.3.1/lib/omniauth/strategy.rb:186:in `call!' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/omniauth-1.3.1/lib/omniauth/strategy.rb:164:in `call' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/omniauth-1.3.1/lib/omniauth/builder.rb:63:in `call' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/rack-1.6.5/lib/rack/conditionalget.rb:25:in `call' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/rack-1.6.5/lib/rack/head.rb:13:in `call' /var/www/discourse/lib/middleware/anonymous_cache.rb:138:in `call' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/params_parser.rb:27:in `call' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/flash.rb:260:in `call' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/rack-1.6.5/lib/rack/session/abstract/id.rb:225:in `context' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/rack-1.6.5/lib/rack/session/abstract/id.rb:220:in `call' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/cookies.rb:560:in `call' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/query_cache.rb:36:in `call' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:653:in `call' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/callbacks.rb:29:in `block in call' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:88:in `__run_callbacks__' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:778:in `_run_call_callbacks' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:81:in `run_callbacks' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/callbacks.rb:27:in `call' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/remote_ip.rb:78:in `call' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/logster-1.2.5/lib/logster/middleware/reporter.rb:31:in `call' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/railties-4.2.7.1/lib/rails/rack/logger.rb:38:in `call_app' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/railties-4.2.7.1/lib/rails/rack/logger.rb:22:in `call' /var/www/discourse/config/initializers/100-quiet_logger.rb:13:in `call_with_quiet_assets' /var/www/discourse/config/initializers/100-silence_logger.rb:26:in `call' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/request_id.rb:21:in `call' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/rack-1.6.5/lib/rack/methodoverride.rb:22:in `call' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/rack-1.6.5/lib/rack/runtime.rb:18:in `call' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/rack-1.6.5/lib/rack/sendfile.rb:113:in `call' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/rack-mini-profiler-0.10.1/lib/mini_profiler/profiler.rb:278:in `call' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/message_bus-2.0.2/lib/message_bus/rack/middleware.rb:62:in `call' /var/www/discourse/lib/middleware/request_tracker.rb:73:in `call' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/railties-4.2.7.1/lib/rails/engine.rb:518:in `call' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/railties-4.2.7.1/lib/rails/application.rb:165:in `call' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/railties-4.2.7.1/lib/rails/railtie.rb:194:in `public_send' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/railties-4.2.7.1/lib/rails/railtie.rb:194:in `method_missing' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/rack-1.6.5/lib/rack/urlmap.rb:66:in `block in call' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/rack-1.6.5/lib/rack/urlmap.rb:50:in `each' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/rack-1.6.5/lib/rack/urlmap.rb:50:in `call' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/unicorn-5.2.0/lib/unicorn/http_server.rb:562:in `process_client' /var/www/discourse/lib/scheduler/defer.rb:85:in `process_client' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/unicorn-5.2.0/lib/unicorn/http_server.rb:658:in `worker_loop' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/unicorn-5.2.0/lib/unicorn/http_server.rb:508:in `spawn_missing_workers' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/unicorn-5.2.0/lib/unicorn/http_server.rb:132:in `start' /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/unicorn-5.2.0/bin/unicorn:126:in `' /var/www/discourse/vendor/bundle/ruby/2.3.0/bin/unicorn:22:in `load' /var/www/discourse/vendor/bundle/ruby/2.3.0/bin/unicorn:22:in `' [/code]

hostname	dragon-app
process_id	675
application_version	1b92d44fb2ecf08948337871da9a3eaa40255cbc
HTTP_HOST	www.[myforum].com
REQUEST_URI	/directory_items?period=all&order=likes_received&_=1483726748445
REQUEST_METHOD	GET
HTTP_USER_AGENT	Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36
HTTP_ACCEPT	application/json, text/javascript, */*; q=0.01
HTTP_REFERER	https://www.[myforum].com/users?period=all
HTTP_X_FORWARDED_FOR	178.202.82.52, 178.202.82.52
HTTP_X_REAL_IP	178.202.82.52
username	[me]
params	
period	all
order	likes_received
_	1483726748445

I can’t reproduce this locally, but from the error it seems like you have some corrupt data. A user is supposed to have a user_stat model automatically created, and one of the users in your database does not.

I can check the database. My first try was this:

SELECT u.id FROM users u WHERE id NOT IN (SELECT user_id FROM user_stats) no rows found

SELECT us.user_id FROM user_stats us WHERE us.user_id NOT IN (SELECT id FROM users) no rows found

Any other ideas?

Maybe this?

SELECT us.user_id
FROM user_stats us
WHERE us.time_read IS NULL

The list under “admin/users/list/active” ist working fine.

The forum is less then 10 Days old. The views up to “users?period=quarterly” are working fine. There is no user older then 2 weeks, for sure, it is not possible at all. At the quarterly view, I can see all users from the database. But “/users?period=all” has still the error.

Thanks a lot, but no rows for that :frowning:

This query should indeed return the row that doesn’t have the user_stat record. If you’re getting no rows back that is very confusing indeed!

Actually it could be there is a record in directory_items for that user_id but is not in user_stat? did you manually delete a user from the database?

Try:

SELECT di.user_id
FROM directory_items AS di
WHERE di.user_id NOT IN (SELECT user_id FROM user_stats)
1 Like

I just confirmed on a new Discourse hosted install (2 days old at most), that users / all works fine.

1 Like

You are the coding wizard :slight_smile: :+1:

I had 5 rows for user id 25 in ith this query and this resolved the issue:

DELETE FROM directory_items WHERE user_id IN
(SELECT di.user_id
FROM directory_items AS di
WHERE di.user_id NOT IN (SELECT user_id FROM user_stats)) 

I deleted the specific user for some reasons yesterday from the admin panel. The deletion is logged in “/admin/logs/staff_action_logs” (deleted username was “Help”) “/admin/users/25/help”

He had 0 postings. And since yesterday I have the first errors in the logs. Maybe there is an issue with deletion of users? To be exactly, the first error was 6 minutes after the deletion.

3 Likes

In case you need it, this are the deleted rows from “directory_items”. Thanks again for helping me out. (Can be closed if you want to)

1 Like

@Lutz sent me a PM about this with repro steps, so I was able to cut out a better fix:

https://github.com/discourse/discourse/commit/86c52c72f66dc81a6fe4621a68af4d892d231749

4 Likes