Sunday, July 19, 2009

An interesting bug/feature with SMB on OSX 10.5

So i'm not a Mac guy, by any stretch of the imagination, but my role forces/encourages me to get to know a bit about Mac. I have several sites that I look after who have a combination of Mac workstation & servers.

One of my sites has an OSX web server, which we recently upgraded to 10.5 (used to run 10.4). This operates in a DMZ and runs 10.5's included version of apache, plus a custom app written in Python. It's custom configured to take web requests via the front end, "pickle" these requests (a python term for dumping the request, compressed, to file). These are then dropped to a polling directory, which is then picked up by an internal server, validated, etc... and processed.

Since the upgrade to 10.5 we've been getting pickling errors, stating that the file (as polled) does not have a valid EoF. After a bit of investigation, we realised that the polling process on the internal network was accessing files whilst they were still in use by the python process on the front end server. Long story short, we worked around it by generating the pickle and once complete copying to the polling directory... I digress.

This got us to thinking... how come we weren't getting a lock, or at least notified that the file was in use/locked. We checked and the appropriate locks were applied on the SMB share (ie. Strict File Locking). So we tested, and found that we could have a file shared via SMB on OSX 10.5(.6) open on several computers simultaneously, with no FLock notification, and in fact could modify & save varying versions of the file, with a "last save wins" policy.

This applied to opening standard text based files with a text editing utility. Interestingly enough, if you use a program that performs it's own file locking checks (ie. Microsoft Excel) - it worked out (eventually) that a file was open. We had several interesting issues, like we could sometimes have both clients open the file at the same time, and neither be marked as read only, or both marked as read only, and sometimes allowed to save. A very strange behaviour to be sure, but the Text Edit/Multiple Edit stuff really worries me.

We've put in a call to Apple, and some apple contacts to see whats going on, will keep up to date on how we go with this.