Subject Re: [firebird-support] Transaction Counters in monitoring tables vs. header page? (FB 2.1.2)
Author Thomas Steinmaurer
HI Vlad,

>> I'm not sure how to interpret the following result in the monitoring
>> tables regarding some transaction counters. I'm querying the monitoring
>> tables of a Firebird 2.1.2 database (Classic on Windows) with an
>> explicitely started client transaction (using IBO) set to read-only,
>> repeatable read, auto-commit = false.
>>
>> With the following result.
>>
>> * In MON$DATABASE
>>
>> MON$OLDEST_TRANSACTION => 29117
>> MON$OLDEST_ACTIVE => 29710
>> MON$OLDEST_SNAPSHOT => 29710
>> MON$NEXT_TRANSACTION => 29710
>>
>> * In MON$TRANSACTIONS
>>
>> I see two records with the following MON$TRANSACTION_IDs:
>>
>> 29710
>
> This is the your transaction
>
>> 29698
>
> My guess is that this is an IBO's service read-committed
> readonly transaction.
>
>> Both marked with MON$STATE = 1
>>
>>
>> * Querying the header page gives the following result:
>>
>> OIT: 29117
>> OAT: 29709
>> OST: 29709
>> NT: 29710
>>
>>
>> A few questions:
>>
>> - Why isn't there a gap between MON$OLDEST_ACTIVE and
>> MON$NEXT_TRANSACTION? I would expect at least a gap of 1.
>
> Tx numbers are recalculated at any transaction start. The
> process run as follows :
> - lock and read header page
> - increment Next value
> - assign Next value to the new tx number
> - update OIT\OAT\OST by values from in-memory variables
> - release and write header page
> - create transaction lock
> - calculate new values of OIT\OAT\OST and save it into in-memory variables
>
> As you can see all tx numbers (except of Next) have the latest
> values at in-memory variables and previous values at header page.

Ah, ok. Thanks for the explanation.

> Should i say that MON$DATABASE reflects in-memory variables ? :)

;-))

>> - Why do I see a record in MON$TRANSACTIONS with MON$TRANSACTION_ID =
>> 29698 but not in any transaction counters either via MON$DATABASE or
>> querying the header page, even if this transaction in MON$TRANSACTIONS
>> is marked as active (MON$STATE = 1?)
>
> If my guess is correct, then
> a) as RC RO transaction is pre-committed (marked as committed in TIP at
> tx start) it not affected OAT\OIT\OST
> b) as this transaction is still active you see it in MON$TRANSACTIONS

Yes, it is a RC RO transaction, thus not affecting OAT/OIT/OST.

>> - Why is there a difference regarding transaction counters when querying
>> MON$DATABASE and the header page?
>
> See above

In my FTSL tool, the idea was to query the header page and to enable the
user to locate the queried OAT value from the header page in the
MON$TRANSACTIONS table. With your explanation above (header page vs.
in-memory variables used by the monitoring tables), it seems there is no
reliable way to do that, right?

Thanks!


--
Best Regards,
Thomas Steinmaurer
LogManager Series - Logging/Auditing Suites supporting
InterBase, Firebird, Advantage Database, MS SQL Server and
NexusDB V2
Upscene Productions
http://www.upscene.com
My blog:
http://blog.upscene.com/thomas/