473,654 Members | 3,096 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

IDENTITY PK-FK corruption of data

Hi All,

I have a problem with a DB2 server of my customer. It is a Debian
Linux running DB2 Express-C. I have an IDENTITY field as PK in a table
and I use this value as FK in another table. Two weeks ago the FK
values got corrupted or mixed up somehow. I also got some warnings
about system temporary table spaces so I created a 16K page size
system temporary table space to be sure. All seemed to be okay until
today. Something happened an hour ago and the FK field now holds
corrupt data. The guys at the local IBM support say that it is most
likely that the client program connecting to DB2 has something to do
with it. I think it doesn't fit the situation becasue the client
program has been shut down for the weekend and it still is besides it
never updates key fields at all. Has anyone seen something like this
before? What can I do?

Thanks,
Sandor
Jun 27 '08 #1
11 2686
stegze wrote:
Hi All,

I have a problem with a DB2 server of my customer. It is a Debian
Linux running DB2 Express-C. I have an IDENTITY field as PK in a table
and I use this value as FK in another table. Two weeks ago the FK
values got corrupted or mixed up somehow. I also got some warnings
about system temporary table spaces so I created a 16K page size
system temporary table space to be sure. All seemed to be okay until
today. Something happened an hour ago and the FK field now holds
corrupt data. The guys at the local IBM support say that it is most
likely that the client program connecting to DB2 has something to do
with it. I think it doesn't fit the situation becasue the client
program has been shut down for the weekend and it still is besides it
never updates key fields at all. Has anyone seen something like this
before? What can I do?
More questions:
Is the PK-FK relationship enforced?
Define corrupt. Do you have children without parents? Children with
wrong parents?

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Jun 27 '08 #2
Hello Serge,
Is the PK-FK relationship enforced?
No it isn't. I wasn't clear about that in the time of my post. There
isn't any enforced relationship. They just use it as if there was one.
They use the corresponding PK value from the parent table when they
insert a record in the child table.
Define corrupt. Do you have children without parents? Children with
wrong parents?
Children with wrong parents. That's it.

Thanks in advance,
Sandor
Jun 27 '08 #3
stegze wrote:
Hello Serge,
>Is the PK-FK relationship enforced?

No it isn't. I wasn't clear about that in the time of my post. There
isn't any enforced relationship. They just use it as if there was one.
They use the corresponding PK value from the parent table when they
insert a record in the child table.
>Define corrupt. Do you have children without parents? Children with
wrong parents?
Children with wrong parents. That's it.
Well, chances are support is right then.
DB2 isn't smart enough to deviously replace one legal FK value with
another legal FK value. This is no random data corruption.
You will need to track which SQL is updating the FK (or could it be that
your PK's are updated ??? Or your "real PK" is changed (since you were
referring to identity columns - reminds me of the movie "Invasion" ;-))).
Even if DB2 itself were to blame this work needs to be done to get to
the bottom of it.

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Jun 27 '08 #4
Serge Rielau wrote:
You will need to track which SQL is updating the FK (or could it be that
your PK's are updated ??? Or your "real PK" is changed (since you were
referring to identity columns - reminds me of the movie "Invasion" ;-))).
Even if DB2 itself were to blame this work needs to be done to get to
the bottom of it.
I have the developers of the client program beside me and they assured
me that there isn't anything in the code that could possibly update a
FK or a PK. Anyway the client program functions fine at many customers
with various versions of DB2 Express-C. Changing keys also would be
stupid because of the business logic. It seems to me that only the PK
values have been changed but I cannot be sure because I don't have
access to recent backups. I know that we should have declared the FK
on the database but it is too late now. I want to understand the issue
better. Isn't there a "maintenanc e task" in DB2 that scans through
tables and does some optimization on identity columns or something
like that? We had a problem earlier and it could be connected to this
one. It was about restoring from backup. After a successful restore we
had to manually override the identity seed values because they were
all set back to one. Since then it became second nature to the system
administrator to check identity seed values after restoring a
database. The support said it has to do something with the memory
cache of DB2 but they wasn't clear about it also nobody cared because
we could solve it with a simple script.
Jun 27 '08 #5

If I may....
On May 19, 7:42 pm, stegze <ste...@gmail.c omwrote:
I know that we should have declared the FK
on the database but it is too late now. I want to understand the issue
better. Isn't there a "maintenanc e task" in DB2 that scans through
tables and does some optimization on identity columns or something
like that?
You can export and load the data, then you can do SET INTEGRITY with
exception table, this is how you can Identify exception rows:
http://publib.boulder.ibm.com/infoce...n/c0004593.htm
Example 5: Check integrity for T1 and T2, and put the violating rows
into exception tables E1 and E2.

SET INTEGRITY FOR T1, T2 IMMEDIATE CHECKED
FOR EXCEPTION IN T1 USE E1,
IN T2 USE E2
We had a problem earlier and it could be connected to this
one. It was about restoring from backup. After a successful restore we
had to manually override the identity seed values because they were
all set back to one. Since then it became second nature to the system
administrator to check identity seed values after restoring a
database. The support said it has to do something with the memory
cache of DB2 but they wasn't clear about it also nobody cared because
we could solve it with a simple script.
How you perform the backup and restore (full backup, incremental...)
Jun 27 '08 #6
stegze wrote:
Serge Rielau wrote:
>You will need to track which SQL is updating the FK (or could it be that
your PK's are updated ??? Or your "real PK" is changed (since you were
referring to identity columns - reminds me of the movie "Invasion" ;-))).
Even if DB2 itself were to blame this work needs to be done to get to
the bottom of it.

I have the developers of the client program beside me and they assured
me that there isn't anything in the code that could possibly update a
FK or a PK.
Just the same DB2 cannot possibly update a PK or FK on its own.
Anyway the client program functions fine at many customers
with various versions of DB2 Express-C. Changing keys also would be
stupid because of the business logic. It seems to me that only the PK
values have been changed but I cannot be sure because I don't have
access to recent backups. I know that we should have declared the FK
on the database but it is too late now. I want to understand the issue
better. Isn't there a "maintenanc e task" in DB2 that scans through
tables and does some optimization on identity columns or something
like that?
No, DB2 has three intersections with IDENTITY columns as far as table
content is concerned:
1. INSERT. Where is looks up the next value in the SEQUENCE, assuming
that it's not GENERATED BY DEFAULT where a vlaue may have been provided
2. LOAD. Same thing, but depending on which action DB2 may re-use
idnetity values provided by the source file, ignore the source and
produce new ones, or simply produce new ones.
3. UPDATE SET DEFAULT
You can ask DB2 to reissue a new value by SETing the identity column
to DEFAULT
That's it. no maintenance code... Once INSERT, UPDATE, LOAD is done teh
rest of DB2 has no knowledge of a column being identity.
We had a problem earlier and it could be connected to this
one. It was about restoring from backup. After a successful restore we
had to manually override the identity seed values because they were
all set back to one. Since then it became second nature to the system
administrator to check identity seed values after restoring a
database. The support said it has to do something with the memory
cache of DB2 but they wasn't clear about it also nobody cared because
we could solve it with a simple script.
When you restore a database the identity columns will pick up with teh
next batch of cached values.
Let's say teh last CAHCE of 20 (default) was: 21-40.
You last INSERT produced 35 before backup.
After restore the next value produced will be 41 because the remaining
cache 36-40 was lost. The same happens on db2stop or when DB2 crashes.

Now, if you "restore" your database using db2look (re-issuing the DDL!)
then DB2 will run the ORIGINAL CREATE TABLE statement and indeed start
with whatever the start value was.
If you then load data using IDENTITY OVERRIDE, then you can see what you
saw.
Anyway, since your client team swears that no LOAD was done, no UPDATE T
SET pk = DEFAULT was done either we are still stuck with mystery ....

Cheers
Serge

PS: Do you have triggers?
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Jun 27 '08 #7
I'll be allowed to do some live tests soon then I'll check everything
you suggested. It seems now that something on the server machine is in
conflict with DB2. I don't know if it could be the cause of the data
change but it is disturbing. Unfortunately it is a Debian Linux and it
isn't supported by IBM so it could be anything. Thank both of you for
all your comments and help.
Jun 27 '08 #8
stegze wrote:
I'll be allowed to do some live tests soon then I'll check everything
you suggested. It seems now that something on the server machine is in
conflict with DB2. I don't know if it could be the cause of the data
change but it is disturbing. Unfortunately it is a Debian Linux and it
isn't supported by IBM so it could be anything. Thank both of you for
all your comments and help.
I simply don't buy any low-level corruption. These things typically
truly look like garbage when they occur.
What you see is "too smart" for a random act.

Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Jun 27 '08 #9
"stegze" <st****@gmail.c omwrote in message
news:91******** *************** ***********@a1g 2000hsb.googleg roups.com...
I'll be allowed to do some live tests soon then I'll check everything
you suggested. It seems now that something on the server machine is in
conflict with DB2. I don't know if it could be the cause of the data
change but it is disturbing. Unfortunately it is a Debian Linux and it
isn't supported by IBM so it could be anything. Thank both of you for
all your comments and help.
It sounds like the problem is related to something like a export and
subsequent import of data, with the identity columns getting regenerated,
instead of using the original values. You need to provide more detail about
all backup/restore and export/import/load operations that were done on the
database.
Jun 27 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

112
10305
by: Andy | last post by:
Hi All! We are doing new development for SQL Server 2000 and also moving from SQL 7.0 to SQL Server 2000. What are cons and pros for using IDENTITY property as PK in SQL SERVER 2000? Please, share your experience in using IDENTITY as PK .
4
1700
by: newtophp2000 | last post by:
We have a table that has an identity field along with 5 other domain fields. The identity field is not declared as a primary key. The table has 3.5 million records. A consultant was hired recently to provide insight. His major recommendation: modify the table to make the identity field a primary key (i.e., alter table add constraint...) Is that sound advice? Is it OK to have a table with identity but no primary keys? What would...
6
74170
by: Who.Really.Really.Cares | last post by:
Hi! I guess this must be a FAQ but I'll give it a try. I've searched the web and usenet archive and found only negative answers. But most of them were dated like 3-4 years back. Hasn't anything changed since then? DB2 V7.2. The problem: I have a table with a primary key GENERATED BY DEFAULT AS IDENTITY. Then I INSERT several rows and force their PK's value. Then I see that my INSERTs haven't modified the value of DB2's internal IDENTITY
2
1798
by: Yaro | last post by:
Hi UDB 8.2.2 Win I am little confused about IDENTITY behavior. create table aaa( c1 integer not null generated by default as identity, c2 integer, primary key (c1)
2
5833
by: Danko Greiner | last post by:
I'm trying to update every table in DataSet, but getting inserted "id_user" gets me an exception: column "id_user" is read only if(_dataSet.HasChanges()) { SqlDataAdapter _adapter; SqlCommandBuilder _builder; SqlConnection conn = new SqlConnection(GlobalSettings.ConnectionString);
3
6991
by: Jason L James | last post by:
Hi all, I recently wrote a vb.net app using oledb to an access database. When I inserted new rows in my datatable the identity column was automatically created. This app used an un-typed dataset. My current app is using sqlClient and a typed dataset that I created by exporting an xsd
2
1697
by: bughunter | last post by:
8.2 UDB win32 I need update a one column in very large table. PK for this table - generated always as identity :-( I can't recreate table without generated always.I don't want write SP or any non-sql script. I'd like simple export & import with commit as I typically do export to file select pk, new_value as upd_col from table
0
8814
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8706
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7304
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6160
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5621
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4149
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4293
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2709
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1915
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.