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

[BUG] Wrong error logged when reclaimFilePageCache fails #13245

Open
TedLyngmo opened this issue May 3, 2024 · 0 comments · May be fixed by #13246
Open

[BUG] Wrong error logged when reclaimFilePageCache fails #13245

TedLyngmo opened this issue May 3, 2024 · 0 comments · May be fixed by #13246

Comments

@TedLyngmo
Copy link

Describe the bug

reclaimFilePageCache doesn't set errno. As a consequence the logged error will be whatever errno was set to prior to the call.

To reproduce

  1. Set errno = EAGAIN.
  2. Make sure rdbSaveInternal is called with arguments that makes reclaimFilePageCache fail.
  3. Watch the log. It will say: Unable to reclaim cache after saving RDB: Resource temporarily unavailable which is not the reason why the internal posix_fadvise failed.

Expected behavior

I'm expecting the serverLog(LL_NOTICE,"Unable to reclaim cache after saving RDB: %s", strerror(errno)); line to print the real cause for the failure.

Additional information

posix_* functions don't set errno but return the error instead. If memory serves me right, it's because these functions came into existence before C11 (where errno was made _Thread_local) so setting and checking errno from different threads wasn't thread safe.

TedLyngmo added a commit to TedLyngmo/redis that referenced this issue May 3, 2024
`reclaimFilePageCache` did not set `errno` but `rdbSaveInternal` which
is logging the error assumed it did. This makes sure `errno` is set.

Fixes redis#13245

Signed-off-by: Ted Lyngmo <ted@lyncon.se>
@TedLyngmo TedLyngmo linked a pull request May 3, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant