Subject Re: [firebird-support] How to limit the number of concurrent users to a database
Author Ann Harrison
On Wed, Jun 13, 2012 at 11:39 AM, Fulvio Senore <mailing@...> wrote:

>
> I have created a custom table, with as many rows as the maximum expected
> number of users. For my program this number will be very small. If the
> user wants a lot of connections there is an unlimited version.
> Each row contains an ID (primary key) and a dummy field.
>
> When a program tries to connect to the database it issues a "SELECT ...
> WITH LOCK" statement in a no-wait transaction, trying to lock the first
> row. If it gets a lock error the row is locked by another user so the
> program tries to lock the second row, and so on.
>
> This solution has the disadvantage of blocking garbage collection so
> each program could commit the locking transaction from time to time.
> This should solve the garbage collection problem.
>

It really depends on your application profile - there are applications
where blocking
garbage collection for the duration of a connection would be catastrophic.


> If a program crashes I suppose that the row will remain locked from some
> time, but I don't know how long it will remain locked. Does anybody know
> this locking time?
>

After a crash, the transaction that took the lock will be declared dead and
its "lock" removed.


Good luck,

Ann


[Non-text portions of this message have been removed]