-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[PRO] Subscription Topics dashboard index appears to be out of date #5259
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Also, question, what does the |
Hey, thanks for the detailed report and sorry for the confusing experience here. Yes, loading a topic runs a
As far as the data issue goes, you could give that script a try to clean up the stale data. I'd also love to figure out how it's getting left behind. If you're interested, maybe we could add some logging to the subscription system to try to track it down. |
Hey, appreciate the response. Followup questions
Also i'm willing to add logging to help you debug, just let me know how to proceed. |
Thanks for your willingness to help track this down -- I'll write up a little patch soon and follow up here. |
Not super urgent on the debugging btw, I've added the cleanup script to our project. Question though, could you explain the difference between the cleanup script and |
Derp, I should have mentioned it -- I think long |
The interesting thing is that we had |
Hypothesis:
This may be why we're seeing stale entries on the dashboard. |
Ok, interesting ... Yes, that seems like it could happen. I had written it off in my previous debugging because there was no evidence in application logs or Pusher's logs that the webhook had failed. But you said "doesn't work as expected," and maybe that's it. I'm remembering a time when I added Sidekiq to an application and we had to change all of our Maybe the same thing is possible here: Pusher is sending the webhook, the app is receiving it, and code is running without an error, but it's just not working. Here's a patch to debug delete_subscription. It adds a couple of Redis round-trips but eye-balling the scale of your current subscription setup, it looks like that should be alright. If I'm mistaken and you think the performance could be a problem, let me know and I can work to integrate this logging data into the main delete_subscription Lua script. Here it is: debug_graphql_subscriptions.rb
# config/initializers/debug_graphql_subscriptions.rb
# frozen_string_literal: true
module DebugDeleteSubscription
def delete_subscription(subscription_id, subscription: nil)
# gather some data before deleting:
sub_key = subscription_key(subscription_id)
sub_data = with_redis { |r| r.get(sub_key) }
if sub_data && sub_data != ""
sub_existed = true
data = JSON.parse(sub_data)
topics = data["topics"]
else
sub_existed = false
end
# do the delete operation:
super
# log some previous state and current state:
Rails.logger.info {
topic = topics.first
topic_key = topic_key(topic)
topic_still_exists = nil
topic_remaining = nil
with_redis do |r|
topic_still_exists = r.exists?(topic_key)
topic_remaining = if topic_still_exists
r.scard(topic_key)
else
-1
end
end
"Gql Sub Del: id=#{subscription_id} existed=#{sub_existed} topic=#{topic} topic_remaining=#{topic_remaining} topic_exists=#{topic_still_exists}"
}
end
end
GraphQL::Pro::Subscriptions::RedisStorage.prepend(DebugDeleteSubscription) I'm hoping this will appear in logs right near the info about the incoming webhook request, which will indicate how that turned out. I'd expect those logs to all have Then, I'd expect any lines with Let me know what you think about putting that in production and then checking some output after a little while. |
Describe the bug
Sometimes when I click on a topic that I see listed in the dashboard, the list of subscriptions is blank. Then when i navigate back out to the index and refresh, that subscription is gone. It seems to be the act of viewing the topic refreshes the data or something?
Screen.Recording.2025-02-27.at.2.50.08.PM.mov
I am pretty sure these aren't just churning out while i'm looking at the page, because I can go back several pages and click on one to reproduce the behavior.
NOTE: we're using the Ably integration.
Versions
graphql
version: graphql-pro (1.29.2)rails
(or other framework): 7.2.1Steps to reproduce
Expected behavior
The topic should not be listed if there are no longer subscribers
Actual behavior
The topic is appearing in the list despite having no subscribers (I think!)
Additional context
This may not be a huge problem, but I want to have confidence that the system is working properly and it's not attempting to send messages to old/unused topics.
The text was updated successfully, but these errors were encountered: