Subject RE: [firebird-support] Maintaining proper generator values
Author Doug Chamberlin
At 11/11/2003 11:53 AM (Tuesday), Wilson, Fred wrote:
>Again, this isn't multi-user safe.

Not completely but, then again, nothing involving generators is completely
multi-user safe since they exist outside transaction control. But we should
still look for ways to make their usage as reliable as possible.

>It's assuming that there is one and only one client application, ever.

No it isn't! Each application can run the same process and thereby help
keep the database healthy.

>If one is getting duplicate generated values, I would suggest that there's a
>problem, and further would suggest finding and fixing the problem
>We use generators on virtually all of our tables, to furnish the PK's.
>We have extremely busy databases. There can be well over 30 clients, many of
>which are inserting new records, into various tables at the rate of 3 ~ 4
>per second, per client.
>We never have problems with duplicated PK's, unless someone's "gone in by
>hand and dinked something"

Same situation here. As you point out, there are still ways to screw up the
situation. I merely recommended an approach to building a self-healing process.

At 11/11/2003 11:50 AM (Tuesday), Artur Anjos wrote:

>I think I'm missing the point here. :-)
>
>Values created by generators shouldn't have any real meaning that just be an
>unique identifier of the row. So, I just don't care if this is a number,
>it's just an ID.

I agree. Did I say something which makes you think I didn't?

>Maintaining 'proper' generator values are quite easy for this: just create a
>generator and use that generator for all tables. A simple trigger that will
>check for null values and get the generator value will be enough for allow
>this value to be set either in the client and/or in the server side.

And if you backup and restore the database without restoring the generator
values how will you reset them? That is the situation which prompted me to
implement my process of having the application check the current values
each time they run.

At 11/11/2003 12:04 PM (Tuesday), Milan Babuskov wrote:
>It can still lead to problems.

How so?

>But, let's not forget the original problem posted by Lee.

I'm not forgetting that. That's why I changed the subject line of my
original post.