[Pharo-dev] [squeak-dev] The .changes file should be bound to a single image

tim Rowledge tim at rowledge.org
Wed Jun 29 17:24:28 UTC 2016

> On 29-06-2016, at 7:08 AM, Levente Uzonyi <leves at caesar.elte.hu> wrote:
> This seems to be a missing #flush after changes are written to the file.
> Without #flush both processes (unix) will maintain their own version of the file in memory.

Pretty much exactly what I was about to type. We just had part of this discussion wrt Scratch project files on the Pi - adding flush/sync etc. 

In many cases letting an OS buffer the buffering of the buffer’s buffer buffer is tolerable - though insane, and wasteful, and a symptom of the lack of careful analysis that seems to pervade the world of software these days - because nothing goes horribly wrong in most cases. Everything eventually gets pushed to actual hardware, the system doesn’t crash, evaporate, get zapped by Zargon DeathRay(™) emissions, the power doesn’t get ripped out etc. Evidently, on a Pi in a classroom we can’t assign quite such a low probability to the Zargon problem.

However, the changes file is supposed to be a transaction log and as such I claim the data ought to hit hardware as soon as possible and in a way that as near as dammit guarantees correct results. So the mega-layer buffering is An Issue so far as I’m concerned.

We also, still, and for decades now, have the behaviour I consider stupid beyond all reason whereby a file write is done by
a) tell the file pointer to move to a certain location
b) think about it 
c) oh, finally write some text to the file.
With the obvious possibility that the file pointer can be changed in b)
Then if you can open-for-write a file multiple times, how much confusion can that actually cause? What about a forked process with nominally the same file objects? Are we at all sure any OS properly deals with it? Are we sure that what is purportedly ‘proper’ makes any sense for our requirements?

The most obvious place where this is an issue is where two images are using the same changes file and think they’re appending. Image A seeks to the end of the file, ‘writes’ stuff. Image B near-simultaneously does the same. Eventually each process gets around to pushing data to hardware. Oops! And let’s not dwell too much on the problems possible if either process causes a truncation of the file. Oh, wait, I think we actually had a problem with that some years ago.

tim Rowledge; tim at rowledge.org; http://www.rowledge.org/tim
"Daddy, what does FORMATTING DRIVE C mean?"

More information about the Squeak-dev mailing list