[net.lang] How many times do you "sync"?

libes@nbs-amrf.UUCP (02/01/84)

Let me throw another superstition on the heap: sync.

I first used it, not really knowing what it did, but it worked (I was
always slow and careful).  Later, I was told that occasionally the
system "didn't hear it the first time" and it was so important that I
should type sync twice "just to be safe".  Then I was told that sync
returns after the write is scheduled but before the write occurs, so
"type it 3 times to give it time to do the write".  While working at
AT&T on a highly-exposed project, I received a memo from my supervisor
explaining that I should "sync 4 times".  Fortunately, by that time I
had figured out what was going on, because shortly after that he asked
me to add code to the shutdown routine to call sync 100 times.

Needless to say, almost everything about UNIX was superstitious to my
supervisor (including the programmers).

Don ("sync" 17 times just to be safe) Libes
{seismo!allegra}!umcp-cs!nbs-amrf!libes

jgpo@iwu1c.UUCP (John, KA9MNK) (02/03/84)

a <-- superstition


When I was the system administrator for some 70's here at BTL, the very
last thing I typed before hitting HALT was:

	sync;sync;sync


Even now, although I am no longer SA (thank Whomever), the very last line
in my .profile reads:

	trap "sync" 0


Is it necessary?  Probably not.  Can it hurt?  No.  Could it help?  Oh, yeah!



  John (You called me at 2 AM to tell me the games are shut off?!?!?) Opalko
  AT&T Bell Laboratories
  Naperville, IL
  {your choice}!ihnp4!jgpo

ark@rabbit.UUCP (Andrew Koenig) (02/03/84)

My normal practice is to type "sync" once, followed by
a slow count to 5, before shutting the system down.
In more than three years as a system administrator,
I have never had any problems that I would think could
be traced to blocks not being written out.

rjk@mgweed.UUCP (Randy King) (02/05/84)

Paranoia?  Maybe.  Slip of the finger?  Possibly.  The theory as it was
told to me is that "sync" is typed 3 times, each followed by a carriage
return.  Why?  Perform the following test:  Type sync N times, randomly
using RETURN and DELETE as the termination character.  Ask a bystander to
tell you how many of those "sync" commands on your screen were executed.
Hence, the thought was that if done N times, at least one would end in a
RETURN and be performed.   Maybe.
						Randy King
						mgweed!rjk

thomas@utah-gr.UUCP (Spencer W. Thomas) (02/06/84)

We've got some code in the shutdown routine that prints out how many
disk blocks are still incore waiting to be written.  It prints it about
20 times, and it usually says 1 1 1 1 1 1 1 1 1 1 1 1 ..., but I have
seen once or twice where it was still 3 or 4 at the end...  The only
delay here is the 300baud printing speed, but it still takes it a couple
of seconds to print out, at least.  So, I always try to wait at least
that long.  Typing sync twice (sync<cr>sync<cr>) takes about this much
time, giving the system time to write out all those blocks.

=Spencer

edhall@randvax.UUCP (02/07/84)

---------------------------------------
Older CPU's with console light displays, like 11/45's, make sync'ing
easy.  Just type `sync', wait until the display is quiescent, and
hit HALT.  Counting to 5 would work as well.

Typing `sync' more than once is indeed a superstition; I've always
typed it only once, and never had a problem.  The caveat in the
manual is a warning for those who would call sync() and halt
immediately afterwards.  The call schedules all necessary I/O,
but most disk drivers will queue the I/O operations and let the
hardware and interrupt routine handle them while control returns
to the user.  After the hardware (and interrupt routine) has been
given a chance to do its thing with the queued buffers, halting is
quite safe.

		-Ed Hall
		decvax!randvax!edhall

ken@ihuxq.UUCP (ken perlow) (02/08/84)

--
I sync 3 times--4 if there's real important files.  The reason
should be obvious: 3 is the number of the trinity, 4 of the
quartering of the earth into active and passive principles.  Geez,
superstition has nothing to do with it.
-- 
                    *** ***
JE MAINTIENDRAI   ***** *****
                 ****** ******    07 Feb 84 [18 Pluviose An CXCII]
ken perlow       *****   *****
(312)979-7261     ** ** ** **
..ihnp4!ihuxq!ken   *** ***

richard@sequent.UUCP (02/09/84)

>>  I sync 3 times--4 if there's real important files.  The reason
>>  should be obvious: 3 is the number of the trinity, 4 of the
>>  quartering of the earth into active and passive principles.  Geez,
>>  superstition has nothing to do with it.

One should obviously never sync 6 times, and in the most dire cases,
sync 7 times.  For those of you not into quasi-religious numerology,
forget it.

			from the confused and bleeding fingertips of
				...!sequent!richard

jreuter@cincy.UUCP (Jim Reuter) (02/09/84)

When I first brought up our 11/60 running 2.8BSD, a hardware
problem with a DZ would cause the system to crash whenever a
DZ input interrupt occurred while the disk drive was doing some
part of a write operation.  This made for a less-than-single-user
system, and I was careful to wait until whatever I had done was
finished before typing anything.  I also typed "sync" after doing
anything important.  Eventually, the need to type "sync" after
everything became a nervous reaction, even after the hardware
was fixed.  Csh to the rescue!  A simple

	alias sync "Go suck an egg!"

has cured me.

	Jim Reuter
	(decvax!cincy!jreuter)

andrew@orca.UUCP (Andrew Klossner) (02/10/84)

Under Unix version 6, the system guaranteed that a call to sync(2)
would block until any previous call to sync(2) had completed, including
the actual writing of blocks to disk.  Thus, when the shell command
"sync;sync" finished and you saw another shell prompt, you could be
confident that the first sync(2) had completed and all dirty blocks had
been flushed.

This guarantee has been dropped from later versions of Unix.  Its loss
is mourned.

  -- Andrew Klossner   (decvax!tektronix!orca!andrew)      [UUCP]
                       (orca!andrew.tektronix@rand-relay)  [ARPA]

rbk@sequent.UUCP (02/11/84)

The best bet is to insure a quiet system.  Most implementations of
update() ("sync" internally) don't touch busy nodes...  So, you might
miss some unless the system is quiet.  Best to unmount all mounted
things first, too (this *will* insure all IO done (depending on
drivers, and particular UNIX in question)).  Since it's very hard to
tell just when inode "x" is in use from *outside* the kernel,
incantations of various sorts might be appropriate :-)

You're not paranoid if they *are* out to get you...
-- 
	Bob Beck
	Sequent Computer Systems
	...ogcvax!sequent!rbk
	(503)627-9809

dave@qtlon.UUCP (02/17/84)

>	Thus, when the shell command
>	"sync;sync" finished and you saw another shell prompt, you could be
>	confident that the first sync(2) had completed and all dirty blocks had
>	been flushed.

SUre, sure, but the second one (which would flush all the non
read-only superblocks again) wouldn't have .....

		Love & XXXXXXXXXXXXs
			Dave (`Why isn't this in unix-wizards?') Lukes
			<U.K>!ukc!qtlon!dave