Contagens de notificação são inconsistentes e incorretas

I am running a week-old very small forum, just updated to the current version, and I am still seeing this very strange behavior. The notification counts (New, etc) do not appear to correspond to any real counts, and change at random.

Currently I see “New (3)”

Clicking on “New” I see no new posts, and the “(3)” is gone.

Clicking back to the home page I no longer see “New (3)” in the menu.

If I reload the page, “New (3)” comes back.

Clicking on “Latest” I see “Unread (2)”, however none of the messages in the list have an unread indicator.

Clicking on “Unread (2)” shows me there are no unread messages.

Sometimes when I click “New”, I see no new messages and an “Unread (1)” indicator

I’ve checked /sidekiq/ and everything looks fine, there are no queued or backed up jobs.

3 curtidas

Can you confirm what version of Discourse your site is on? It should be shown near the top of your site’s admin dashboard.

3 curtidas

2.5.0.beta4

( 74db317974 )

2 curtidas

Do you have any muted tags or categories.

Do you have a consistent repro?

2 curtidas

Nothing muted, and this has continued to happen even with new activity in the forum. Feel free to make an account if you’d like to see it first-hand. (I haven’t actually confirmed if other people see this or if it’s unique to my account.)

Look in your admin section are there any warnings, is sidekiq running ?

1 curtida

No warnings, sidekiq looks fine. Assuming I’m reading this right.

Are you running cloudflare or a similar CDN. I’ve noticed some notification latency with cloudflare, even with the acceleration turned off. Rocket loader for example.

1 curtida

Oh I missed this… so something is consistently wrong. This means the server is telling the client there are a bunch of new topics, but then when you drill in they are missing.

I have seen this happen before with scheduled posts … do you use them? Debugging this is a bit tricky, we need to get the list of topic_ids the client thinks are new

If this is happening now run:

SELECT 
           u.id AS user_id,
           topics.id AS topic_id,
           topics.created_at,
           highest_staff_post_number highest_post_number,
           last_read_post_number,
           c.id AS category_id,
           tu.notification_level
FROM topics
JOIN users u on u.id = 1
JOIN user_stats AS us ON us.user_id = u.id
JOIN user_options AS uo ON uo.user_id = u.id
JOIN categories c ON c.id = topics.category_id
LEFT JOIN topic_users tu ON tu.topic_id = topics.id AND tu.user_id = u.id
LEFT JOIN category_users ON category_users.category_id = topics.category_id AND category_users.user_id = 1
WHERE u.id = 1 AND
      
      topics.archetype <> 'private_message' AND
      ((1=0) OR ("topics"."deleted_at" IS NULL AND topics.created_at >= GREATEST(CASE
                  WHEN COALESCE(uo.new_topic_duration_minutes, 2880) = -1 THEN u.created_at
                  WHEN COALESCE(uo.new_topic_duration_minutes, 2880) = -2 THEN COALESCE(u.previous_visit_at,u.created_at)
                  ELSE ('2020-05-13 00:36:29.100619'::timestamp - INTERVAL '1 MINUTE' * COALESCE(uo.new_topic_duration_minutes, 2880))
               END, us.new_since, '2020-05-07 14:46:17') AND tu.last_read_post_number IS NULL AND COALESCE(tu.notification_level, 2) >= 2 AND topics.created_at > '2020-05-07 14:46:17' AND (category_users.last_seen_at IS NULL OR topics.created_at > category_users.last_seen_at))) AND
      
      
      topics.deleted_at IS NULL AND
      
      NOT (
        last_read_post_number IS NULL AND
        COALESCE(category_users.notification_level, 1) = 0
      )

UNION ALL

SELECT 
           u.id AS user_id,
           topics.id AS topic_id,
           topics.created_at,
           highest_staff_post_number highest_post_number,
           last_read_post_number,
           c.id AS category_id,
           tu.notification_level
FROM topics
JOIN users u on u.id = 1
JOIN user_stats AS us ON us.user_id = u.id
JOIN user_options AS uo ON uo.user_id = u.id
JOIN categories c ON c.id = topics.category_id
LEFT JOIN topic_users tu ON tu.topic_id = topics.id AND tu.user_id = u.id
LEFT JOIN category_users ON category_users.category_id = topics.category_id AND category_users.user_id = 1
WHERE u.id = 1 AND
       topics.updated_at >= us.first_unread_at AND 
      topics.archetype <> 'private_message' AND
      (("topics"."deleted_at" IS NULL AND tu.last_read_post_number < topics.highest_staff_post_number AND COALESCE(tu.notification_level, 1) >= 2) OR (1=0)) AND
      
      
      topics.deleted_at IS NULL AND
      
      NOT (
        last_read_post_number IS NULL AND
        COALESCE(category_users.notification_level, 1) = 0
      )

replacing user_id = 1 with your user id (you can find it by running select id, username from users where username = 'yourusername')

If this is happening can you install data explorer and see what is going on.

1 curtida

Sem CDN, sem publicações agendadas. Esta é apenas uma instalação padrão do Discourse em Docker, em um VPS da Linode, nada extravagante.

Acabei de instalar o plugin Data Explorer e agora nem consigo carregar a página de configurações. Ela trava com um erro de JS no console:

workbox-strategies.prod.js:1 Uncaught (in promise) no-response: no-response :: [{"url":"https://forum.livevideotech.today/admin/site_settings"}]
    at a.makeRequest (https://forum.livevideotech.today/javascripts/workbox/workbox-strategies.prod.js:1:2145)
1 curtida

Alguns plugins personalizados? Você está na branch beta ou em testes-passados? Se estiver na beta, pode mudar para testes-passados por enquanto.

Um plugin: GitHub - discourse/discourse-solved: Allow accepted answers on topics · GitHub

Estou na versão 2.5.0.beta4, à qual cheguei após um processo de instalação padrão e executando as atualizações sugeridas.

Não sei como mudar para uma branch específica; além disso, isso parece arriscado, já que um dos poucos resultados de busca ao tentar descobrir como fazer isso foi de alguém que teve migrações de banco de dados falhas ao tentar isso.

Conectei ao banco de dados pela linha de comando e executei a consulta, e não houve resultados:

discourse(#         last_read_post_number IS NULL AND
discourse(#         COALESCE(category_users.notification_level, 1) = 0
discourse(#       );
 user_id | topic_id | created_at | highest_post_number | last_read_post_number | category_id | notification_level
---------+----------+------------+---------------------+-----------------------+-------------+--------------------
(0 linhas)

discourse=#

Para esclarecer: no estado atual, ao carregar a página inicial, vejo “Novo (1)”. Ao clicar em “Novo (1)”, não vejo nenhuma nova postagem. Ao voltar para a página inicial, o “Novo (1)” desaparece. Ao recarregar a página, ele volta a aparecer.

Você está executando um commit antigo e não está na versão beta

Pode reconstruir pelo console. O explorador de dados deve funcionar.

It says I’m on 4078b22887 which is exactly one commit behind master.

Oh right, sorry, can you confirm data explorer is still broken after you enable it on site settings? Also can you try in a different browser (Firefox/chrome) does the work box error persist?

Vou lidar com o problema do explorador de dados mais tarde; não quero ficar reconstruindo o fórum e tirando-o do ar toda vez. Vou apenas executar as consultas na linha de comando.

Status atual: “Novos (4)”

 user_id | topic_id |         created_at         | highest_post_number | last_read_post_number | category_id | notification_level
---------+----------+----------------------------+---------------------+-----------------------+-------------+--------------------
       1 |      116 | 2020-05-13 06:48:33.784078 |                   1 |                       |           5 |
       1 |      118 | 2020-05-13 07:29:47.423296 |                   1 |                       |           5 |
       1 |      117 | 2020-05-13 06:52:39.448473 |                   1 |                       |          13 |
       1 |       31 | 2020-05-03 14:13:53.109324 |                   4 |                     3 |           7 |                  2

Ao clicar em “Novos (4)”, vejo três posts: 118, 117 e 116. O topic_id 31 não aparece.

Ao voltar para a página inicial, o contador passa a mostrar “Novos (3)”.

Os resultados da consulta continuam retornando os mesmos 4 registros.

4 curtidas

Ok, isso é interessante. Você consegue navegar até o tópico 31? Há algo de estranho nele? Esse é um tópico não lido (last_read_post_number é 3)… a consulta indica que achamos que você tem 3 novos e 1 não lido.

Fico pensando se talvez algo esteja acontecendo no lado do cliente para você com o cache do web worker.

Você está no Chrome ou Firefox… consegue tentar o outro… consegue tentar seu navegador em modo anônimo sem extensões?

4 curtidas

Oh @martin, acabamos de descobrir um bug… Por acaso, você está silenciando alguma tag?

Existe um bug onde as contagens ficam incorretas se você tiver tags silenciadas e QUALQUER tópico que seja 100% sem tags; eles acabam faltando na lista de não lidos.

3 curtidas

Não tenho 100% de certeza se isso é exatamente o seu problema, @aaronpk… mas essa correção já está incluída em:

6 curtidas