redis / redis

Redis is an in-memory database that persists on disk. The data model is key-value, but many different kind of values are supported: Strings, Lists, Sets, Sorted Sets, Hashes, Streams, HyperLogLogs, Bitmaps.

Home Page:http://redis.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] Wrong error logged when `reclaimFilePageCache` fails

TedLyngmo opened this issue · comments

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.