Subject Re: [firebird-php] Hits and stats counters ....
Author Lester Caine
masotti wrote:
> Hi Lester,
> Lester Caine wrote:
>> I've had a problem with bitweaver since day one, but since it only happened very
>> occasionally I'd chosen to ignore it. With the traffic through my sites
>> increasing it has become a more serious problem, and I need to look at doing
>> something about it.
>> Query is simple enough
>> UPDATE LC_HITS SET hits = hits + 1, last_hit = NOW WHERE content_id = xxx
> Default transactions are IBASE_WRITE | IBASE_CONCURRENCY | IBASE_WAIT,
> so you need to alter default transaction in client library to IBASE_READ

Should I need to add IBASE_READ to that, and why not IBASE_WAIT there ?

> To update database don't use default connection, but peek another
> connection from pool and use an explicit transaction.
> To peek a different connection from pool to the same database may work
> if you define a different user or a different connection character set
> so both connection will be pooled.
> $db0 = ibase_pconnect ( $dbase, $another_user, $another_pass );
> $trx = ibase_trans ( IBASE_WRITE | IBASE_COMMITTED |
> $qry = "LC_HITS SET hits = hits + 1, last_hit = NOW WHERE content_id = xxx";
> $cnt = ibase_query ( $db0, $qry );
> ibase_commit ( $tr0 );
> This is only theory, never had chance to test.

I was considering adding an 'update' connection - I have used that in the past,
but only on windows apps where the main connection may be open for some time (
with packaged transactions ). Up until now I'd not considered it necessary since
PHP packages up each page and should not be holding anything open? THAT is why
the deadlock seems to be strange since the only 'update' reading pages is the
hits counter.

I've switched daily stats off at the moment - that updates a set of count
records for a single day and gives the same problem :(

Lester Caine - G8HFL
Contact -
L.S.Caine Electronic Services -
EnquirySolve -
Model Engineers Digital Workshop -
Firebird -