Closed
Description
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 commentedon Dec 30, 2021
@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 commentedon Dec 31, 2021
Sounds like you are misusing
WAIT
. Hard to say more - it is not clear what you are doing.akshatraika commentedon Dec 31, 2021
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 commentedon Jan 1, 2022
I doubt you can use WAIT for that purpose.
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 commentedon Jan 11, 2022
Hmm, alright. Thanks, appreciate the help.
chore: sync master (#2051)
fix: set timeout for WAIT command. Fixes redis#1963