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
rdbSaveInternalis called with arguments that makesreclaimFilePageCachefail. - Watch the log. It will say:
Unable to reclaim cache after saving RDB: Resource temporarily unavailablewhich is not the reason why the internalposix_fadvisefailed.
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.