The code that triggers the HashMapSet
is as follows:
ctx = context.WithValue(ctx, "isCli", true)
numberOfCreatedGroups := 0
for _, ip := range ips {
time.Sleep(time.Millisecond * time.Duration(delay))
if err := ih.dc.add(ctx, ip, uint32(0)); err != nil {
log.WithFields(log.Fields{
GroupIp: ip,
}).Info(err)
continue
} else {
numberOfCreatedGroups += 1
}
}
The add
function also calls the function below:
_, err := db.Repo.HashMapSet(ctx, key, groupIp, id)
where HashMapSet function calls the actual HSet function which can be seen as below.
func (r *repository) HashMapSet(ctx context.Context, key string, values ...interface{}) (int64, error) {
intCmd := r.Client.HSet(ctx, key, values...)
log.WithFields(log.Fields{"key": key, "values": values, "result": intCmd}).Debug("repo-hashmapset")
return intCmd.Result()
}
Below is what I see as an output:
DEBU[2023-03-13T22:44:35.191449159+03:00] repo-hashmapset key=ig_groupids/55 result="hset ig_groupids/55 239.254.1.175 432: context deadline exceeded" values="[239.254.1.175 432]"
INFO[2023-03-13T22:44:35.191572577+03:00] context deadline exceeded group-ip=239.254.1.175
DEBU[2023-03-13T22:44:35.211896763+03:00] repo-hashmapset key=ig_groupids/55 result="hset ig_groupids/55 239.254.1.176 432: context deadline exceeded" values="[239.254.1.176 432]"
INFO[2023-03-13T22:44:35.212052712+03:00] context deadline exceeded group-ip=239.254.1.176
DEBU[2023-03-13T22:44:35.232327292+03:00] repo-hashmapset key=ig_groupids/55 result="hset ig_groupids/55 239.254.1.177 432: context deadline exceeded" values="[239.254.1.177 432]"
INFO[2023-03-13T22:44:35.232373678+03:00] context deadline exceeded group-ip=239.254.1.177
DEBU[2023-03-13T22:44:35.252736679+03:00] repo-hashmapset key=ig_groupids/55 result="hset ig_groupids/55 239.254.1.178 432: context deadline exceeded" values="[239.254.1.178 432]"
INFO[2023-03-13T22:44:35.252776536+03:00] context deadline exceeded group-ip=239.254.1.178
DEBU[2023-03-13T22:44:35.273120216+03:00] repo-hashmapset
Is it related to context.WitValue
? Because It seems to me that same context is used for all invocations here. After some times like 9 to 10 seconds, the application starts producing these context deadline exceeded
outputs. I am using redis
not redis-sentinel
. Also can it be related to way of creating or initializng Redis connection? Which I didn't pass any timeout or something like that while initilization phase.