[colug-432] Troubleshooting Suggestions: File Truncation Issue
William E. T.
linux.hacker at gmail.com
Sun Jan 10 08:15:02 EST 2016
Sorry my description wasn't clear. The link created is a hard link; I
thought this is a fairly common pattern of writing data to disk for unix
systems.
The most concise way to precisely convey what's happening may be with some
trace exerts:
Expected:
open("main.pre.tsidx", O_RDWR|O_CREAT|O_EXCL|O_TRUNC, 0600) = 3
write(3, "\33[?1049h\33[?1h\33=\33[1;61r\33[?12;25h\33"..., 29549) = 29549
close(3) = 0
link("main.pre.tsidx", "main.tsidx") = 0
unlink("main.pre.tsidx") = 0
stat("main.tsidx", {st_mode=S_IFREG|0600, st_size=29549, ...}) = 0
So we write 29549 bytes to main.pre.tsidx so we would expect main.tsidx to
have a size of 29549 bytes and in this example it does (the st_size in the
stat).
If we iterate over that process thousands to millions of times, we'll see
the following happen:
open("main.pre.tsidx", O_RDWR|O_CREAT|O_EXCL|O_TRUNC, 0600) = 3
write(3, "\33[?1049h\33[?1h\33=\33[1;61r\33[?12;25h\33"..., 29549) = 29549
close(3) = 0
link("main.pre.tsidx", "main.tsidx") = 0
unlink("main.pre.tsidx") = 0
stat("main.tsidx", {st_mode=S_IFREG|0600, st_size=0, ...}) = 0
In this case, we would expect main.tsidx to have a size of 29549 bytes, but
it has a size of 0
The actual application is a proprietary application; its a niche product,
but its run by a number of companies in town. The pastebin in the first
e-mail (http://pastebin.com/mFmZzYEL) has the a trace excerpt it from the
actual application.
The above examples are from tracing the C program I wrote to isolate this
problem (https://gist.github.com/w3ttr3y/167b349d2ab67e3aa9d2 it is ugly
and probably missing some checks to ensure things suceeded, so I'd only
trust it if you trace it and then verify everything suceeded in the trace);
The big difference between the proprietary application and my demo is the
real one uses explicit paths instead of relative; both files are in the
same directory though so crossing a partition boundary isn't an issue
I didn't explicitly answer your questions, question by question. I started
to, but I started thinking of all sorts of ambiguities so I hoped trace
excerpts would more concisely document what is happening.
I really appreciate you taking the time to try and help me,
--Bill
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.colug.net/pipermail/colug-432/attachments/20160110/96e9890b/attachment.html
More information about the colug-432
mailing list