Skip to content

Commit ea71e26

Browse files
committed
add text about idletime, emergency actions
1 parent f16a4bb commit ea71e26

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,13 @@ To avoid filling Redis storage with stale subscription data:
131131
132132
Heroku users should set up `use_redis_object_on_cleanup` setting to `false` due to [limitations in Heroku Redis](https://devcenter.heroku.com/articles/heroku-redis#connection-permissions).
133133
134+
### Limitations
135+
136+
The `GraphQL::AnyCable::Cleaner` uses [IDLETIME](https://redis.io/commands/object-idletime/) for detecting how long the object was inactive.
137+
It is a good way to detect inactive subscriptions, but `IDLETIME` is updated every time, not only when new subscriptions are, but when we read it
138+
It means that `broadcasting` also updates the `IDLETIME`, which does not give us the ability to detect useless subscriptions for cleaning
139+
It will be resolved in the next versions
140+
134141
## Configuration
135142
136143
GraphQL-AnyCable uses [anyway_config] to configure itself. There are several possibilities to configure this gem:
@@ -166,6 +173,21 @@ GraphQL-AnyCable uses [anyway_config] to configure itself. There are several pos
166173
167174
And any other way provided by [anyway_config]. Check its documentation!
168175
176+
## Emergency Actions
177+
178+
In situations, when you don't set `subscription_expiration_seconds`, have a lot of inactive subscriptions and `GraphQL::AnyCable::Cleaner` doesn`t help in that, you can do the
179+
next actions for clearing subscriptions
180+
181+
1. Set `config.subscription_expiration_seconds`. After that, the new subscriptions will have `TTL`
182+
2. Through the `redis_prefix` (look at the `Configuration` block) change the redis prefixes, which uses for storing keys
183+
3. Run the script, using the old `redis_prefix` (the default value is `graphql`)
184+
```ruby
185+
redis = GraphQL::AnyCable.redis
186+
redis.scan_each("graphql-subscription:*") do |key|
187+
redis.del(key) if redis.ttl(key) < 0 # Remove it, because it is an old record
188+
end
189+
```
190+
169191
## Data model
170192

171193
As in AnyCable there is no place to store subscription data in-memory, it should be persisted somewhere to be retrieved on `GraphQLSchema.subscriptions.trigger` and sent to subscribed clients. `graphql-anycable` uses the same Redis database as AnyCable itself.

0 commit comments

Comments
 (0)