openresty / openresty/lua-resty-redis

will read_reply() lost message in Pub/Sub?

Open
#108 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Lua
Stars
2k
Forks
447
Avg merge
2h 24m
Merged PRs (30d)
3

Description

I have write a Pub/Sub code in worker_init and work very well,thanks agentzh abundant issue support ,code under here:

local res, err = red:subscribe("nginx")
    while not ngx.worker.exiting() do
        repeat
            local key, err = red:read_reply()
            if not key then--here timeout
                ngx.log(ngx.INFO,"err is :",err)
                break
            end
            key = key[3]
            local value,err = red2:get(key)
            if value == nil or (type(value) == "boolean" and not value) then
                ngx.log(ngx.INFO,"value is null: ",value)
                break
            else
                ngx.log(ngx.INFO,"value is set to LRU: ",value)
                c:set(key,value)
            end
        until true
    end

Will red:read_reply() lost message when PUB command send in redis is between timeout or handle logic and next read_reply ?
As I know about epoll implemention, I think it will not lost in handle business logic,but I don't know about timeout error
if read_reply have timeout error,will PUB message lost?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the worker_init loop shown in the issue and the lua-resty-redis read_reply() documentation or implementation. Trace how timeout errors and queued Pub/Sub replies are handled between calls, then verify whether a message can be lost during a timeout or between reads.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua, redis
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.