> > And you know - I've run same tests on ~ Mar 9 snapshot
> > without any problems.
> >> 
> >> That was before I changed the code to pre-fill the file --- 
> >> now it takes longer to init a log segment.  And we're only
> >> using a plain SpinAcquire, not the flavor with a longer timeout.
> 
> > xlog.c revision 1.55 from Feb 26 already had log file
> > zero-filling, so ...
> 
> Oh, you're right, I didn't study the CVS log carefully enough.  Hmm,
> maybe the control file lock isn't the problem.  The abort() in
> s_lock_stuck should have left a core file --- what is the backtrace?

After 10 times increasing DEFAULT_TIMEOUT in s_lock.c
I got abort in xlog.c:626 - waiting for insert_lck.
But problem is near new log file creation code: system
goes sleep just after new one is created.

Vadim

Fri, 16 Mar 2001 16:01:48 -0800
"Mikheev, Vadim" <vmikheev@SECTORBASE.COM>
RE: Stuck spins in current 
"Mikheev, Vadim" <vmikheev@SECTORBASE.COM> writes:
> xlog.c revision 1.55 from Feb 26 already had log file
> zero-filling, so ...
>> 
>> Oh, you're right, I didn't study the CVS log carefully enough.  Hmm,
>> maybe the control file lock isn't the problem.  The abort() in
>> s_lock_stuck should have left a core file --- what is the backtrace?

> After 10 times increasing DEFAULT_TIMEOUT in s_lock.c
> I got abort in xlog.c:626 - waiting for insert_lck.
> But problem is near new log file creation code: system
> goes sleep just after new one is created.

Have you learned any more about this?  Or can you send your test program
so other people can try it?

In the meantime, even if it turns out there's a different problem here,
it seems clear to me that it's a bad idea to use a plain spinlock to
interlock xlog segment creation.  The spinlock timeouts are not set
high enough to be safe for something that could take several seconds.
Unless someone objects, I will go ahead and work on the change I
suggested yesterday to not hold the ControlFileLockId spinlock while
we are zero-filling the new segment.

			regards, tom lane

Sat, 17 Mar 2001 11:59:26 -0500
Tom Lane <tgl@sss.pgh.pa.us>
Re: Stuck spins in current 
"Mikheev, Vadim" <vmikheev@SECTORBASE.COM> writes:
> And you know - I've run same tests on ~ Mar 9 snapshot
> without any problems.

Oh, I see it:

Process A is doing GetSnapShotData.  It holds SInvalLock and calls
ReadNewTransactionId, which wants XidGenLockId.

Process B is doing GetNewTransactionId.  It holds XidGenLockId and
has run out of XIDs, so it needs to write a NEXTXID log record.
Therefore, it calls XLogInsert which wants the insert_lck.

Process C is inside XLogInsert on its first xlog entry of a transaction.
It holds the insert_lck and wants to put its XID into MyProc->logRec,
for which it needs SInvalLock.

Ooops.

At this point I must humbly say "yes, you told me so", because if I
hadn't insisted that we needed NEXTXID records then we wouldn't have
this deadlock.

It looks to me like the simplest answer is to take NEXTXID records
out again.  (Fortunately, there doesn't seem to be any comparable
cycle involving OidGenLock, or we'd need to think of a better answer.)
I shall retire to lick my wounds, and make the changes tomorrow ...

			regards, tom lane

Sat, 17 Mar 2001 22:07:11 -0500
Tom Lane <tgl@sss.pgh.pa.us>
Re: Stuck spins in current 
> At this point I must humbly say "yes, you told me so", because if I

No, I didn't - I must humbly say that I didn't foresee this deadlock,
so "I didn't tell you so" -:)

Anyway, deadlock in my tests are very correlated with new log file
creation - something probably is still wrong...

Vadim



Sat, 17 Mar 2001 22:16:49 -0800
"Vadim Mikheev" <vmikheev@sectorbase.com>
Re: Stuck spins in current 
"Vadim Mikheev" <vmikheev@sectorbase.com> writes:
> Anyway, deadlock in my tests are very correlated with new log file
> creation - something probably is still wrong...

Well, if you can reproduce it easily, seems like you could get in there
and verify or disprove my theory about where the deadlock is.

Or send the testbed and I'll try ...

			regards, tom lane

Sun, 18 Mar 2001 01:22:03 -0500
Tom Lane <tgl@sss.pgh.pa.us>
Re: Stuck spins in current 