Skip to content

i/o timeout error only for Wait() functions #1963

Closed
@akshatraika

Description

@akshatraika

Hi, I'm seeing the following error on running the Wait() command in go-redis in a private repo:

read tcp xxx.xxx.xxx.x:xxx1-> xxx.xxx.xxx.x:xxx9: i/o timeout

Surprisingly, I use LPUSH, HSET commands in the same function which pass but as soon as I want to do a WAIT, the service errors out. The service connects to redis fine and I have verified the LPUSH and HSET inputs in the db and the transactions went through successfully.

Is there any reason why only the WAIT command would error out in this? The function call looks like: service.redis.Wait(1, time.Second*5)

Activity

akshatraika

akshatraika commented on Dec 30, 2021

@akshatraika
Author

@vmihailenco The fix you pushed adds a timeout which is good, thank you for that. The issue I'm facing still remains though, maybe I'm running the WAIT() command incorrectly. I have 0 replicas for redis, just the master node. When I post a transaction through LPush or HSet, the transaction is run asynchronously which causes my application to crash when I try to query for the rows I added. How do I block the application till the transaction I posted is finished? Wait(0, time.Seconds * 5) doesn't seem to work. (I have 0 replicas - because of that Wait(1, time.Seconds*5) will not work either)

vmihailenco

vmihailenco commented on Dec 31, 2021

@vmihailenco
Collaborator

Sounds like you are misusing WAIT. Hard to say more - it is not clear what you are doing.

akshatraika

akshatraika commented on Dec 31, 2021

@akshatraika
Author

I basically want to run LPush and HGet commands synchronously. In this case, I have an integration test where I push the data into redis and want to query redis for the inserted data shortly after. Since the redis transactions run asynchronously, the write operations in redis may not finish before the GET operations are made. This leads to the test failing and it is non deterministic. Is there a way to achieve this? I thought if I use WAIT(), that will block the thread till all previous transactions are completed in redis.

Please note that I have no replicas running in my architecture, just the master node for redis.

vmihailenco

vmihailenco commented on Jan 1, 2022

@vmihailenco
Collaborator

I doubt you can use WAIT for that purpose.

this leads to the test failing and it is non deterministic.

You can try something like https://pkg.go.dev/github.com/stretchr/testify@v1.7.0/require#Eventually to wait until condition is met.

akshatraika

akshatraika commented on Jan 11, 2022

@akshatraika
Author

Hmm, alright. Thanks, appreciate the help.

added a commit that references this issue on Mar 19, 2022
335d946
added a commit that references this issue on Mar 2, 2024
333fee1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @vmihailenco@akshatraika

        Issue actions

          i/o timeout error only for Wait() functions · Issue #1963 · redis/go-redis