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

Sample code for Generic Object Mapping hangs indefinitely #591

Closed
mpjunior92 opened this issue Jul 25, 2024 · 3 comments · Fixed by #594
Closed

Sample code for Generic Object Mapping hangs indefinitely #591

mpjunior92 opened this issue Jul 25, 2024 · 3 comments · Fixed by #594
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@mpjunior92
Copy link

Bug

Running sample code from https://github.com/redis/rueidis/tree/main/om#generic-object-mapping using a JSONRepository causes the repo to hang indefinitely.

Initial findings

singleClient gets stuck at DoCache operation:

func (c *singleClient) DoCache(ctx context.Context, cmd Cacheable, ttl time.Duration) (resp RedisResult) {
retry:
	resp = c.conn.DoCache(ctx, cmd, ttl)
	if c.retry && c.isRetryable(resp.NonRedisError(), ctx) {
		goto retry // <-- execution falls here
	}
	if err := resp.NonRedisError(); err == nil || err == ErrDoCacheAborted {
		cmds.PutCacheable(cmd)
	}
	return resp
}

Returned error:

"failed to fetch the cache because EXEC was aborted by redis or connection closed"

Steps to reproduce:

Expected result

Program executes through completion without hanging.

Environment

  • OS: Linux matheus 6.5.0-44-generic # 44~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue Jun 18 14:36:16 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
  • go version: go version go1.21.6 linux/amd64
  • Redis version: Redis server v=7.2.5 sha=00000000:0 malloc=jemalloc-5.3.0 bits=64 build=d284576ab9ca3cc5
  • rueidis version: v1.0.41
@rueian
Copy link
Collaborator

rueian commented Jul 25, 2024

Hi @mpjunior92,

Thank you for reporting! It is indeed a bug that is being stuck. We need to exclude the case of ErrDoCacheAborted from c.isRetryable(). That is, we should fix it by making it return false when resp.NonRedisError() == ErrDoCacheAborted.

But the fix won't let you use NewJSONRepository either. To use NewJSONRepository, your redis must have redisjson module installed.

@rueian rueian added bug Something isn't working good first issue Good for newcomers labels Jul 25, 2024
@ajayd-san
Copy link
Contributor

Hey, can i take this up ?

@rueian
Copy link
Collaborator

rueian commented Jul 25, 2024

Hey, can i take this up ?

Sure! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants