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

False PK\FK violation could be reported when attachment used isc_dpb_no_garbage_collect flag [CORE5110] #5394

Closed
firebird-issue-importer opened this issue Feb 12, 2016 · 11 comments

Comments

@firebird-issue-importer

Submitted by: @hvlad

Relate to CORE5111

Attachments:
trace_log_for_two_Tx.7z

isc_dpb_no_garbage_collect flag is respected by constraint checking code and false "key violation" error could be reported.

Possible scenario:

tx1: insert key 1
tx1: rollback
tx2: insert key 1

violation of PRIMARY or UNIQUE KEY constraint

The case was reported by IBPhoenix customer

Commits: 6af5a2f f965e75 FirebirdSQL/fbt-repository@8b95e73 FirebirdSQL/fbt-repository@26b231e

====== Test Details ======

Confirmed exception with PK/UK violation on WI-V3.0.0.32332 (11-feb-2016), 2.5.6.26970 (05-feb-2016):
- SQLCODE: -803 ; - violation of PRIMARY or UNIQUE KEY constraint "TEST_ID_UNQ" on table "TEST"
- Problematic key value is ("ID" = 1) ; -803 ; 335544665
No such error on WI-T4.0.0.32371, WI-V2.5.6.26979.

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Feb 12, 2016

Modified by: @hvlad

assignee: Vlad Khorsun [ hvlad ]

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Feb 12, 2016

Modified by: @hvlad

summary: False FK violation could be reported when attachment used isc_no_garbage_collect flag => False PK\FK violation could be reported when attachment used isc_dpb_no_garbage_collect flag

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Feb 12, 2016

Commented by: @hvlad

There are two possible ways to fix the issue (known to me at moment):

1. ignore no_gc flag in VIO_get_current() and backout dead record version, or

2. make VIO_get_current() to reconstruct previous record version (which will
be placed over currently dead primary record version).

Patch with (1) was already tested by customer, therefore i commit it.
(2) could be implemented later, when necessary

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Feb 12, 2016

Modified by: @hvlad

Link: This issue relate to CORE5111 [ CORE5111 ]

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Feb 12, 2016

Modified by: @hvlad

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

resolution: Fixed [ 1 ]

Fix Version: 3.0 RC2 [ 10048 ]

Fix Version: 2.5.6 [ 10721 ]

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Feb 13, 2016

Modified by: @pavel-zotov

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

QA Status: No test => Deferred

Test Details: Can`t find ability to create attachment with isc_dpb_no_garbage_collect = 1 using fdb.
Waiting for reply from P. Cisar.

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Feb 17, 2016

Modified by: @pavel-zotov

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

Test Details: Can`t find ability to create attachment with isc_dpb_no_garbage_collect = 1 using fdb.
Waiting for reply from P. Cisar.

=>

Implementation will be possible after release of fdb 1.5.1.

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Mar 4, 2016

Modified by: @pavel-zotov

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

Test Details: Implementation will be possible after release of fdb 1.5.1. => Can not reproduce neither on 3.0 RC1 nor on build #⁠32332 of 11-feb-2016 (closest to 12-feb-2016 when fix was committed - see http://sourceforge.net/p/firebird/code/62965 ).

Python code (DB already has table "TEST(ID INT PRIMARY KEY)" ):

import fdb
print('fdb version: '+fdb.__version__)
conn = fdb.connect(dsn='localhost/3309:e30', user='SYSDBA', password='masterke', no_gc=1)
print(conn.firebird_version)

#⁠ ho helps: customTPB = ( [ fdb.isc_tpb_concurrency ] )

tx1=conn.trans()
tx2=conn.trans()

tx1.begin( tpb=customTPB )
tx2.begin( tpb=customTPB )

cur1=tx1.cursor()
cur2=tx2.cursor()

cur1.execute("insert into test(id) values(1)")
tx1.rollback()

cur2.execute("insert into test(id) values(1)")
tx2.rollback()

No errors in output, it prints only versions of fdb (1.5.1) and FB .
Any suggestions ? Is it subject of races ?

I've attached two trace logs which can illustrate what python connection did.

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Mar 4, 2016

Modified by: @pavel-zotov

Attachment: trace_log_for_two_Tx.7z [ 12912 ]

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Mar 4, 2016

Modified by: @pavel-zotov

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

QA Status: Deferred => Done successfully

Test Details: Can not reproduce neither on 3.0 RC1 nor on build #⁠32332 of 11-feb-2016 (closest to 12-feb-2016 when fix was committed - see http://sourceforge.net/p/firebird/code/62965 ).

Python code (DB already has table "TEST(ID INT PRIMARY KEY)" ):

import fdb
print('fdb version: '+fdb.__version__)
conn = fdb.connect(dsn='localhost/3309:e30', user='SYSDBA', password='masterke', no_gc=1)
print(conn.firebird_version)

#⁠ ho helps: customTPB = ( [ fdb.isc_tpb_concurrency ] )

tx1=conn.trans()
tx2=conn.trans()

tx1.begin( tpb=customTPB )
tx2.begin( tpb=customTPB )

cur1=tx1.cursor()
cur2=tx2.cursor()

cur1.execute("insert into test(id) values(1)")
tx1.rollback()

cur2.execute("insert into test(id) values(1)")
tx2.rollback()

No errors in output, it prints only versions of fdb (1.5.1) and FB .
Any suggestions ? Is it subject of races ?

I've attached two trace logs which can illustrate what python connection did.

=>

Confirmed exception with PK/UK violation on WI-V3.0.0.32332 (11-feb-2016), 2.5.6.26970 (05-feb-2016):
- SQLCODE: -803 ; - violation of PRIMARY or UNIQUE KEY constraint "TEST_ID_UNQ" on table "TEST"
- Problematic key value is ("ID" = 1) ; -803 ; 335544665
No such error on WI-T4.0.0.32371, WI-V2.5.6.26979.

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Mar 4, 2016

Modified by: @pavel-zotov

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment