Skip to content
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

Add cancelation metadata to Redis #154

Closed
wants to merge 1 commit into from
Closed

Conversation

tempusfrangit
Copy link

Add some cancelation metadata to redis that allows API to introspect the stream and message ID from the prediction ID. This allows api to perform an XDEL on the redis message when a cancelation is received. The only time an XDEL should happen is if the prediction has not started.

API will be responsible to check XPENDING and/or the prediciton cache. Additionally API should DEL the meta key when it performs a cancelation or when the prediction completes.

key format: meta:cancelation:<prediction_id> and it contains json in the form of: {"stream_id": "<stream key>", "msg_id": "<redis message id>"}

Add some cancelation metadata to redis that allows API to introspect the
stream and message ID from the prediction ID. This allows api to perform
an `XDEL` on the redis message when a cancelation is received. The only
time an `XDEL` should happen is if the prediction has not started.

API will be responsible to check `XPENDING` and/or the prediciton cache.
Additionally API should `DEL` the meta key when it performs a
cancelation or when the prediction completes.

key format: `meta:cancelation:<prediction_id>` and it contains json
in the form of: `{"stream_id": "<stream key>", "msg_id": "<redis message
id>"}`
@tempusfrangit
Copy link
Author

tempusfrangit commented Nov 21, 2024

This is an example of how we can signal the message id so that API can snipe the redis message out of the queue using an XDEL when a cancelation is received. This is a much cleaner way of handling cancelations that have not been picked up.

Director can still decide if it wants to propagate cancelations to cog.

API can look up this key, and if it exists, XDEL the message and move on ignoring the cancelation key that director would normall rely on (or we could still set it, if we want).

TTL is subject to discussion on this new key.

Additionally XCLAIM should return an empty list if the message has been XDEL and XDEL/XACK on a non-existent message should be a noop

@@ -102,6 +112,15 @@ local id = redis.call('XADD', key_stream, '*', unpack(fields))
-- Add a notification to the notifications stream
redis.call('XADD', key_notifications, 'MAXLEN', '1', '*', 's', selected_sid)

if prediction_id ~= "" then
local key_prediction_meta_cancelation = ':meta:cancelation:' .. prediction_id
redis.CALL('SET', key_prediction_meta_cancelation, '{"stream_id":"' .. key_stream .. ',"prediction_id":"' .. prediction_id .. ',"msg_id":"' .. id .. '"}')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
redis.CALL('SET', key_prediction_meta_cancelation, '{"stream_id":"' .. key_stream .. ',"prediction_id":"' .. prediction_id .. ',"msg_id":"' .. id .. '"}')
redis.CALL('SET', key_prediction_meta_cancelation, '{"stream_id":"' .. key_stream .. ',"msg_id":"' .. id .. '"}')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants