ln -sf /var/log/scribe/wtf_125 /var/log/scribe/wtf_current
appears as:
2014/07/08 13:28:03 "/var/log/scribe/wtf_current": DELETE
in strace it looks like this:
stat("/var/log/scribe/wtf_current", {st_mode=S_IFREG|0600, st_size=29, ...}) = 0
lstat("/var/log/scribe/wtf_current", {st_mode=S_IFLNK|0777, st_size=23, ...}) = 0
stat("/var/log/scribe/wtf_125", {st_mode=S_IFREG|0600, st_size=29, ...}) = 0
symlink("/var/log/scribe/wtf_125", "/var/log/scribe/wtf_current") = -1 EEXIST (File exists)
unlink("/var/log/scribe/wtf_current") = 0
symlink("/var/log/scribe/wtf_125", "/var/log/scribe/wtf_current") = 0
At the same time, this works as expected:
rm /var/log/scribe/wtf_current; ln -s /var/log/scribe/wtf_125 /var/log/scribe/wtf_current
2014/07/08 13:29:23 "/var/log/scribe/wtf_current": DELETE
2014/07/08 13:29:23 "/var/log/scribe/wtf_current": CREATE
unlinkat(AT_FDCWD, "/var/log/scribe/wtf_current", 0) = 0
... different process ...
stat("/var/log/scribe/wtf_current", 0x7fffcbc6baa0) = -1 ENOENT (No such file or directory)
symlink("/var/log/scribe/wtf_125", "/var/log/scribe/wtf_current") = 0
The next C program gives correct events with probability ~80%:
#include <unistd.h>
int main() {
unlink("/var/log/scribe/wtf_current");
usleep(1);
symlink("/var/log/scribe/wtf_125", "/var/log/scribe/wtf_current");
return 0;
}
Removing usleep leads to absence of CREATE events.
I suspect race condition somewhere.