[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
- Set
errno = EAGAIN
. - Make sure
rdbSaveInternal
is called with arguments that makesreclaimFilePageCache
fail. - Watch the log. It will say:
Unable to reclaim cache after saving RDB: Resource temporarily unavailable
which is not the reason why the internalposix_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.