Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autonomous transactions wrongly inherit run-time flags of "parent" transaction [CORE3525] #3882

Closed
firebird-issue-importer opened this issue Jun 16, 2011 · 12 comments

Comments

@firebird-issue-importer

Submitted by: @hvlad

Currently autonomous transactions inherits characteristics of "parent" transaction (such as isolation level, read-only, wait mode).
Code that starts autonomous transaction just copied "parent" transaction's flags. This is wrong and at least inefficient.
Autonomous transaction should copy only flags which describes transaction characteristics, i.e. flags which could be set by transaction_options() function.

Commits: eb41aaa ecb52d3

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Jun 16, 2011

Modified by: @hvlad

assignee: Vlad Khorsun [ hvlad ]

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Jun 16, 2011

Modified by: @hvlad

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

Fix Version: 2.5.1 [ 10333 ]

Fix Version: 3.0 Alpha 1 [ 10331 ]

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Jun 19, 2011

Modified by: @dyemanov

summary: Autonomous transactions should not inherit run-time flags of "parent" transaction => Autonomous transactions wrongly inherits run-time flags of "parent" transaction

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Jun 19, 2011

Modified by: @dyemanov

summary: Autonomous transactions wrongly inherits run-time flags of "parent" transaction => Autonomous transactions wrongly inherit run-time flags of "parent" transaction

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Apr 23, 2013

Modified by: @pcisar

status: Resolved [ 5 ] => Closed [ 6 ]

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Dec 20, 2015

Commented by: @pavel-zotov

Can anyone explain me, what exactly flags should be inherited by ATX ?
In jrd/tra.cpp one may see that WAIT / lock_timeout, and also isol. level DO present in this function:

$ cat -n tra.cpp | tail --lines=+2616 | head -100
2616 static void transaction_options(thread_db* tdbb,
2617 jrd_tra* transaction,
2618 const UCHAR* tpb, USHORT tpb_length)
2619 {
. . .
2630 SET_TDBB(tdbb);
2631
2632 if (!tpb_length)
2633 return;
2634
2635 const UCHAR* const end = tpb + tpb_length;
2636
2637 if (*tpb != isc_tpb_version3 && *tpb != isc_tpb_version1)
2638 ERR_post(Arg::Gds(isc_bad_tpb_form) <<
2639 Arg::Gds(isc_wrotpbver));
2640
2641 RelationLockTypeMap lockmap;
2642
2643 TriState wait, lock_timeout; ------------------------------------------------------------- <<< ----------------
2644 TriState isolation, read_only, rec_version;
2645 bool anylock_write = false;
. . .
2696 case isc_tpb_wait: ------------------------------------------------------------------ <<< ---------------
2697 if (!wait.assignOnce(true))
2698 {
2699 if (!wait.asBool())
2700 {
2701 ERR_post(Arg::Gds(isc_bad_tpb_content) <<
2702 Arg::Gds(isc_tpb_conflicting_options) << Arg::Str("isc_tpb_wait" ) <<
2703 Arg::Str("isc_tpb_nowait"));
2704 }
2705 else
2706 {
2707 ERR_post(Arg::Gds(isc_bad_tpb_content) <<
2708 Arg::Gds(isc_tpb_multiple_spec) << Arg::Str("isc_tpb_wait"));
2709 }
2710 }
2711 break;
. . .

I haven't any understanding of this code (as C++ at all) but this ticket still hasn't appropriate .fbt in test repo.

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Dec 20, 2015

Commented by: @hvlad

> Can anyone explain me, what exactly flags should be inherited by ATX ?

From tra.h

// flags derived from TPB, see also transaction_options() at tra.cpp
const ULONG TRA_OPTIONS_MASK = (TRA_degree3 | TRA_readonly | TRA_ignore_limbo | TRA_read_committed |
TRA_autocommit | TRA_rec_version | TRA_no_auto_undo | TRA_restart_requests);

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Dec 20, 2015

Commented by: @pavel-zotov

SQL> select * from mon$transactions;
...
MON$ISOLATION_MODE 3 --- ==> TRA_degree3; TRA_read_committed; TRA_rec_version
MON$LOCK_TIMEOUT -1
MON$READ_ONLY 0 -- ==> TRA_readonly
MON$AUTO_COMMIT 0 -- ==> TRA_autocommit
MON$AUTO_UNDO 1 -- ==> TRA_no_auto_undo
MON$STAT_ID 15

Seems that mon$transactions can`t help in defining of TRA_ignore_limbo & TRA_restart_requests values.
Am I right ?

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Dec 20, 2015

Commented by: @hvlad

> Seems that mon$transactions can`t help in defining of TRA_ignore_limbo & TRA_restart_requests values.
Yes

The ticket was mostly about *not* copying flags that shouln't be copied.

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Dec 20, 2015

Commented by: @pavel-zotov

> The ticket was mostly about *not* copying flags that shouln't be copied.

That's mean that test should check only following flags:

382 const ULONG TRA_system = 0x1L; // system transaction
384 const ULONG TRA_reconnected = 0x4L; // reconnect in progress
388 const ULONG TRA_prepare2 = 0x40L; // transaction has updated RDB$TRANSACTIONS
390 const ULONG TRA_invalidated = 0x100L; // transaction invalidated by failed write
391 const ULONG TRA_deferred_meta = 0x200L; // deferred meta work posted
396 const ULONG TRA_restart_requests = 0x4000L; // restart all requests in attachment
398 const ULONG TRA_precommitted = 0x10000L; // transaction committed at startup
399 const ULONG TRA_own_interface = 0x20000L; // tra_interface was created for internal needs

But no any field in mon$transactions can be found for them - so, I'll try to find something in FB-Python doc ( e.g. in "Advanced Transaction Control").

It's interesting also that [NO] WAIT | LOCK_TIMEOUT parameter is not specified:
1) neither in mask:

(TRA_degree3 | TRA_readonly | TRA_ignore_limbo | TRA_read_committed |
TRA_autocommit | TRA_rec_version | TRA_no_auto_undo | TRA_restart_requests);

2) nor in enumeration "Flag definitions for tra_flags".

So what about current behaviour (implicit "wait"-inheritance in ATx) - is it wrong or no ?

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Dec 20, 2015

Commented by: @hvlad

a) You can't check flags that is not set using user API ( for ex.i.e. internal run-time flags).
b) Wait mode can't be set via SQL statement thus it is inherited. You can check if it is true or not. It is not stored in tx flags, btw

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Jan 18, 2016

Modified by: @pavel-zotov

QA Status: No test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants