[comp.sys.mac.programmer] RAM Cache corrupt multi-user databases?

tim@hoptoad.uucp (Tim Maroney) (05/02/90)

In article <1729.263cb9a5@vaxa.uwa.oz> a_dent@vaxa.uwa.oz writes:
>I've read the technote about the RAM cache and I'm a little worried.  
>The RAM cache will only write its contents to disk when the application exits 
>or the volume is flushed (or if a block is so old it gets bumped out).
>
>What's the effect on servers and databases?  If I'm using a database such as
>FoxBase+/Mac, I can have a datafile on the server and be doing all the right
>things with file-locking to guarantee that my updates aren't corrupted by
>some other user.  However, if my updates are only going as far as the RAM
>cache, then all the file-locking in the world won't help.
>
>Surely someone else has thought of this?
>
>Is the preferred solution to disable the RAM cache under program control

It's not a problem.  Network file systems on the Mac don't allow
server-user caching.  It's not an insoluble problem, but generally no
wants to mess around with distributed-cache-synchronization protocols.

In other words, there may be a cache of the local file system on the
server, in which case all clients are looking in the same cache storage
and there's no conflict.  There is never a cache of a remote file
system on a client, just to avoid the synchronization problems you've
deduced.

Incidentally, I'm not sure whether the external file system mechanism
disables caching itself, or whether network file systems turn off
CacheCom themselves when they need to.  But this shouldn't matter to
someone writing software that runs on a network file system.
-- 
Tim Maroney, Mac Software Consultant, sun!hoptoad!tim, tim@toad.com

"Conversion, fastidious Goddess, loves blood better than brick, and feasts
 most subtly on the human will." - Virginia Woolf, "Mrs. Dalloway"

levin@bbn.com (Joel B Levin) (05/04/90)

In article <7986@goofy.Apple.COM> chewy@apple.com (Paul Snively) writes:
|In article <1990Apr30.212653.2004@uswmrg2.UUCP> steve@uswmrg2.UUCP (Steve 
|Martin) writes:
|> In article <1729.263cb9a5@vaxa.uwa.oz> a_dent@vaxa.uwa.oz writes:
|> >I've read the technote about the RAM cache and I'm a little worried.  
|> >The RAM cache will only write its contents to disk when the application exits
|> >or the volume is flushed (or if a block is so old it gets bumped out).
|> I don't think this is correct.  As I recall the RAM cache that Apple has
|> implemented is a write-through cache.
|Bad news.  The original poster was correct; our cache isn't write-through. 
|And yeah, that does mean that your "writes" aren't really written until 
|the next FlushVol.

On the other hand, I believe that closing a file (the way that most
applications do) does a FlushVol; at least, closing a file will write
its cached (dirty) pages to disk at that time.  If you are opening and
closing files a lot this reduces your window of vulnerability a fair
amount.

	/JBL
=
Nets: levin@bbn.com  |  "There were sweetheart roses on Yancey Wilmerding's
 or {...}!bbn!levin  |  bureau that morning.  Wide-eyed and distraught, she
POTS: (617)873-3463  |  stood with all her faculties rooted to the floor."

dorner@pequod.cso.uiuc.edu (Steve Dorner) (05/04/90)

Personally, I call FlushVol after every 2 seconds of inactivity, as part of
normal housekeeping.
--
Steve Dorner, U of Illinois Computing Services Office
Internet: s-dorner@uiuc.edu  UUCP: {convex,uunet}!uiucuxc!dorner