Subject Re: OAT/OIT/OST questions
Author Dmitry Yemanov
27.03.2015 15:13, Fernando P. Nájera Cano wrote:
>
> I have a few questions about the transaction numbers.
>
> The documentation at
> http://www.firebirdsql.org/manual/gstat-example-header.html says that
> OST is normally the same as OAT.

I'd replace "normally" with "ideally" ;-)

> * When could OST be different to OAT?

Long-running snapshot transactions + concurrent load.

> * Is it possible to simulate this situation (OST != OAT) by using isql?
> If yes, how?

With two ISQLs - easily:

SQL> set transaction read committed;
SQL> select mon$oldest_transaction, mon$oldest_snapshot,
mon$oldest_active from mon$database;

MON$OLDEST_TRANSACTION MON$OLDEST_SNAPSHOT MON$OLDEST_ACTIVE
====================== =================== =================
1 817 817

SQL> commit;
SQL> set transaction read committed;
SQL> select mon$oldest_transaction, mon$oldest_snapshot,
mon$oldest_active from mon$database;

MON$OLDEST_TRANSACTION MON$OLDEST_SNAPSHOT MON$OLDEST_ACTIVE
====================== =================== =================
1 817 820

The difference is that the second ISQL was connected in between and
executed some queries in a snapshot transaction.

> * If OST and OAT are different, which one is higher?

OAT.

> My current understanding is that OIT is always the lowest of the
> three

Not always.

> and I think that OAT should be less or equal than OST.

Usually, the sequence is either OIT <= OST <= OAT or OST <= OIT <= OAT.

> Also, given that OST is the oldest snapshot transaction:

No, it's not, the name is very confusing. In fact, this is the oldest
transaction which data other transactions may need in their snapshots.

> * What happens if there is no current snapshot transaction?

OST should catch up OAT.

> * If the database had never had a snapshot transaction, would this
> value be 1 (or 0) while OAT and OIT have moved on?

OST should be equal to OAT.

> And one extra question:
>
> * If I'm in the middle of a transaction and the network connection
> breaks, what happens to the OAT/OIT/OST - in particular, does any of
> them get stuck? If yes, for how long?

Only OIT may get stuck in this case, it depends on how many changes were
performed by the failed connection in transactions that were active at
the moment of network faliure. Only the sweep will move OIT forward
afterwards.


Dmitry