Hi, Gluster Experts,
In glusterfs version 3.12.3, There seems a
“fstat” issue for ctime after we use fsync,
We have a demo execute binary which write some data and then do fsync for this file, it named as
“tt”,
Then run tar command right after
“tt” command, it will always error with
“tar: /mnt/test/file1.txt: file changed as we read it”
The command output is list as the below, the source code and volume info configuration attached FYI,
This issue will be 100% reproducible! (/mnt/test is mountpoint of glusterfs volume
“test” , which the volume info is attached in mail)
------------------------------------------------------------------
./tt;tar -czvf /tmp/abc.gz /mnt/test/file1.txt
mtime:1531247107.272000000
ctime:1531247107.272000000
tar: Removing leading `/' from member names
/mnt/test/file1.txt
tar: /mnt/test/file1.txt: file changed as we read it
----------------------------------------------------------------------
After my investigation, the xattrop for changelog is later than the fsync response , this is mean:
In function
“afr_fsync_cbk” will call afr_delayed_changelog_wake_resume (this, local->fd, stub);
In our case, it always a pending changelog , so glusterfs save the metadata information to stub, and handle pending
changelog first,
But the changelog will also change the ctime, from the packet captured by tcpdump, the response packet of xattrop
will not include the metadata information, and the wake_resume also not handle this metadata changed case.
So in this case, the metadata in mdc_cache is not right, and when cache is valid, the application will get WRONG
metadata!
For verify my guess, if I change the configuration for this volume
“gluster v set test md-cache-timeout 0” or
“gluster v set export stat-prefetch off”
This issue will be GONE!