dbTalk Databases Forums  

revised readu example

comp.databases.pick comp.databases.pick


Discuss revised readu example in the comp.databases.pick forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Dale
 
Posts: n/a

Default Re: revised readu example - 05-26-2010 , 12:59 AM






Frank,

In D3/Linux I never ran into a locking problem, and I had used lots of
transaction bracketing that could lock thousands of records. I think
the Pick locking mechanism is pretty dynamic. (Someone correct me if
I'm wrong.)

As of the secondary locks by other vendors of Pick like system I
cannot comment yea or nay.

Dale

On May 25, 11:29*pm, "Frank Winans" <fwin... (AT) sbcglobal (DOT) net> wrote:
Quote:
Years ago I wrote here in CDP

Also , here's an example of READU three-clause usage;

READU * *myfile, *"george" * *LOCKED
* *CRT * 'name george is locked by someone else;':
* *CRT * ' *item may or may not exist'
END THEN
* *CRT * 'george did exist, and we now own a lock on that name'
END ELSE
* CRT * 'george *does not exist, but we now own a lock on the name'
END

But I'm advised that the LOCKED clause really should have a line

* * * RELEASE *myfile, "george"

since historically some licensee companies have had a Basic that created

a secondary lock if the item was found locked by another. *So in a loopthis

little-regarded lock might eventually give the

'Maximum number of item locks exceeded' *message...

Also, would anybody care to hazard a guess how generously that limit is allocated on
d3/linux

and/or d3/nt? * I've never happened to run afoul of it yet, but stuff happens, they say...

Frank

Reply With Quote
  #2  
Old   
Frank Winans
 
Posts: n/a

Default revised readu example - 05-26-2010 , 01:29 AM






Years ago I wrote here in CDP

Quote:
Also , here's an example of READU three-clause usage;


READU myfile, "george" LOCKED
CRT 'name george is locked by someone else;':
CRT ' item may or may not exist'
END THEN
CRT 'george did exist, and we now own a lock on that name'
END ELSE
CRT 'george does not exist, but we now own a lock on the name'
END


But I'm advised that the LOCKED clause really should have a line

RELEASE myfile, "george"

since historically some licensee companies have had a Basic that created

a secondary lock if the item was found locked by another. So in a loop this

little-regarded lock might eventually give the

'Maximum number of item locks exceeded' message...



Also, would anybody care to hazard a guess how generously that limit is allocated on
d3/linux

and/or d3/nt? I've never happened to run afoul of it yet, but stuff happens, they say...



Frank

Reply With Quote
  #3  
Old   
Ross Ferris
 
Posts: n/a

Default Re: revised readu example - 05-26-2010 , 02:06 AM



program locka
open "","md" to md else stop "??? WOW - no MD"
c = 1
while c do
print c
readu rec from md,"AnyOldKeyThatIsNot":c else c += 1
repeat

When (if?) it stops running you have your answer

(At times I have to wonder if I'm the ONLY person who writes little
test programs to try & figure out how/why things work the way they do.
I'm sure I'm not, but some of the questions posed at times make me
wonder ...)

Reply With Quote
  #4  
Old   
Tony Gravagno
 
Posts: n/a

Default Re: revised readu example - 05-26-2010 , 12:00 PM



Ross Ferris wrote:
Quote:
(At times I have to wonder if I'm the ONLY person who writes little
test programs to try & figure out how/why things work the way they do.
I'm sure I'm not, but some of the questions posed at times make me
wonder ...)
You're not. If I think a question can easily be answered with code I
have a SCRATCH.VME and SCRATCH.FSI account that I use for test ditties
like that.

For Frank - I've never heard of a secondary lock. Without a Locked
clause, code will simply hang and wait for access to a record. As
soon as the record is available and the lock is released, one of the
processes attempting to get the record will lock it. There's no need
for a secondary lock. D3 does have a queuing mechanism for
first-come-first-serve access to records, the list-lockq verb shows
the queue of processes waiting on any given record. I don't know if
or how this is implemented in other platforms.

Rather than working around a problem that you may (or may not)
encounter on some as-yet-unidentified system, I recommend that you
simply code to spec, and if there is a bug, then file a report with
the vendor and adjust as required.

With regard to RELEASE, it can be a double-edged sword. I believe
that like GOTO, a RELEASE with no arguments is usually a lazy
programmer's escape hatch out of bad code. RELEASE with arguments
should only be used if the code is saying "I really thought I needed
exclusive access to this record but I explicitly decided that I do
not". I would not add RELEASE because some platform "might" have a
double-lock bug.

HTH
T

Reply With Quote
  #5  
Old   
ceden
 
Posts: n/a

Default Re: revised readu example - 05-26-2010 , 07:26 PM



On 26 May, 18:00, Tony Gravagno
<address.is.in.po... (AT) removethis (DOT) com.invalid> wrote:
Quote:
Ross Ferris wrote:
(At times I have to wonder if I'm the ONLY person who writes little
test programs to try & figure out how/why things work the way they do.
I'm sure I'm not, but some of the questions posed at times make me
wonder ...)

You're not. *If I think a question can easily be answered with code *I
have a SCRATCH.VME and SCRATCH.FSI account that I use for test ditties
like that.

For Frank - I've never heard of a secondary lock. *Without a Locked
clause, code will simply hang and wait for access to a record. *As
soon as the record is available and the lock is released, one of the
processes attempting to get the record will lock it. *There's no need
for a secondary lock. *D3 does have a queuing mechanism for
first-come-first-serve access to records, the list-lockq verb shows
the queue of processes waiting on any given record. *I don't know if
or how this is implemented in other platforms.

Rather than working around a problem that you may (or may not)
encounter on some as-yet-unidentified system, I recommend that you
simply code to spec, and if there is a bug, then file a report with
the vendor and adjust as required.

With regard to RELEASE, it can be a double-edged sword. *I believe
that like GOTO, a RELEASE with no arguments is usually a lazy
programmer's escape hatch out of bad code. *RELEASE with arguments
should only be used if the code is saying "I really thought I needed
exclusive access to this record but I explicitly decided that I do
not". *I would not add RELEASE because some platform "might" have a
double-lock bug.

HTH
T
f*cking genius

why pick is obscure and unnessary

Reply With Quote
  #6  
Old   
Frank Winans
 
Posts: n/a

Default Re: revised readu example - 05-26-2010 , 09:04 PM



"Tony Gravagno" <address.is.in.posts (AT) removethis (DOT) com.invalid> wrote

Quote:
Ross Ferris wrote:
(At times I have to wonder if I'm the ONLY person who writes little
test programs to try & figure out how/why things work the way they do.
I'm sure I'm not, but some of the questions posed at times make me
wonder ...)

You're not. If I think a question can easily be answered with code I
have a SCRATCH.VME and SCRATCH.FSI account that I use for test ditties
like that.

For Frank - I've never heard of a secondary lock. Without a Locked
clause, code will simply hang and wait for access to a record. As
soon as the record is available and the lock is released, one of the
processes attempting to get the record will lock it. There's no need
for a secondary lock. D3 does have a queuing mechanism for
first-come-first-serve access to records, the list-lockq verb shows
the queue of processes waiting on any given record. I don't know if
or how this is implemented in other platforms.

Rather than working around a problem that you may (or may not)
encounter on some as-yet-unidentified system, I recommend that you
simply code to spec, and if there is a bug, then file a report with
the vendor and adjust as required.

With regard to RELEASE, it can be a double-edged sword. I believe
that like GOTO, a RELEASE with no arguments is usually a lazy
programmer's escape hatch out of bad code. RELEASE with arguments
should only be used if the code is saying "I really thought I needed
exclusive access to this record but I explicitly decided that I do
not". I would not add RELEASE because some platform "might" have a
double-lock bug.

HTH
T
Weeeel, it kind of depends; if this was for use in our own shop, or one of
our clients on D3 or MVBase, I'd certainly forgo the paranoid programming.
If I was writing a small routine or code snippet for widespread {esp. free}
distribution, I'd tend to add lots of armor... I have contact with a large old
commercial package that was written to survive porting to a bewildering array
of vendor platforms, so maybe I've just gotten a little bent from reading that code...

About the test-instead-of-post_a_question, I was 2 parts too lazy to backup
before, and restore after, such testing and couldn't justify even the slight risk
that this would have odd side effects on our system. But I was 3 parts curious
if historically or on other flavors of pick there were modestly interesting limits
on how many item locks you could maintain at once, or if the systems handled
exceeding that rather badly.

This all started when I saw a post by one
Michael M Mason entered on Dec 19, 1997
about his non-D3 experience;
Quote:
A gotcha that I've come across on the Pick I'm using (Open Architecture)
arises with the LOCKED clause. If you try to do something like this:-

100 READU rec FROM wherever,id LOCKED
RQM
GOTO 100
END THEN ....

Quote:
...it turns out that the READU sets a new lock each time it executes and
eventually the lock table fills up with the usual dire consequences. You
have to do a RELEASE wherever,id straight after the LOCKED clause.





Perhaps calling it a 'secondary lock' was a poor move on my part...

Frank

Reply With Quote
  #7  
Old   
Tony Gravagno
 
Posts: n/a

Default Re: revised readu example - 05-27-2010 , 10:45 AM



Quote:
This all started when I saw a post by one
Michael M Mason entered on Dec 19, 1997
about his non-D3 experience;

A gotcha that I've come across on the Pick I'm using (Open Architecture)
arises with the LOCKED clause. If you try to do something like this:-

100 READU rec FROM wherever,id LOCKED
RQM
GOTO 100
END THEN ....


...it turns out that the READU sets a new lock each time it executes and
eventually the lock table fills up with the usual dire consequences. You
have to do a RELEASE wherever,id straight after the LOCKED clause.
That was a 1997 quote on a platform that was obsolete by 1993. We're
literally talking about a release-specific problem in a new platform
(v1 or v2, there was no OA v3) from almost 20 years ago. Since then,
Sequoia, mvEnterprise, Advanced Pick, and now D3 have derived from
that base and chances are virtually nil that this issue remains.

About the concept of READU/LOCKED, the process should not have created
an entry in the lock-queue table (if there was one at the time!) when
the LOCKED clause was taken. The locked clause explicitly says "don't
assert a lock or wait for the record, I'm outta here!" (Makes me
wonder if some platforms have implemented a WAITFOR clause that allows
a process to wait for some number of milliseconds before giving up.)

I'm all in favor of cautious programming but lines must be drawn. Any
number of disasters can be accommodated in code, but within
(subjective) reason. Coding against old bugs and possible failures in
the underlying platform seems like paranoia at best, and yields
seriously bloated, non-performant, and difficult to maintain code at
worst.

Has this thread outlived its potential usefulness?
T

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.