i accidentally ran an UPDATE statement without the WHERE clause on a
customer's live customers table. After saying "oh shit" many many times, i
closed the ad-hoc query tool, hoping DB2 would see my disconnect and
rollback the implicit transaction. (Either that or DB2 would have completed
the updated before it saw my disconnect).
So, there were two possibilities:
a) 0 row(s) affected
b) 1,398,287 row(s) affected
What actually happened is disturbing, and is my question. When queried to
see how many rows were affected, it was
c) 832,284 row(s) affected
How is it that an aborted UPDATE statement would affect only 60% of the
rows. Using a modern transactional RDMS means that the update was atomic,
and either all rows were affected, or no rows were affected.
So, there are probably three answers that could be posted in response:
a) You must be mistaken; it didn't only affect 60% of the rows.
b) Of course updates in DB2 are not atomic. That would lead to performance
problems that are not acceptable in production environments.
c) Your customer must have set some database option that disables all
transactional integrity. And DB2 has to have this option, becuase otherwise
there could be performance problems that are not acceptable in production
environments.
So pick your answer, or add your own.
Ian 24 2484
On Nov 10, 6:26 am, "Ian Boyd" <ian.msnews...@ avatopia.comwro te:
i accidentally ran an UPDATE statement without the WHERE clause on a
customer's live customers table. After saying "oh shit" many many times, i
closed the ad-hoc query tool, hoping DB2 would see my disconnect and
rollback the implicit transaction. (Either that or DB2 would have completed
the updated before it saw my disconnect).
So, there were two possibilities:
a) 0 row(s) affected
b) 1,398,287 row(s) affected
What actually happened is disturbing, and is my question. When queried to
see how many rows were affected, it was
c) 832,284 row(s) affected
How is it that an aborted UPDATE statement would affect only 60% of the
rows. Using a modern transactional RDMS means that the update was atomic,
and either all rows were affected, or no rows were affected.
So, there are probably three answers that could be posted in response:
a) You must be mistaken; it didn't only affect 60% of the rows.
b) Of course updates in DB2 are not atomic. That would lead to performance
problems that are not acceptable in production environments.
c) Your customer must have set some database option that disables all
transactional integrity. And DB2 has to have this option, becuase otherwise
there could be performance problems that are not acceptable in production
environments.
So pick your answer, or add your own.
Ian
It seems that if the update was (as you say) a single SQL statement,
the DBMS's basic ACID guarantees would provide that it either execute
completely or not at all. I would vote for a DBMS bug.
Joe Weinstein at BEA Systems
or
If you are not executing SQL directly through an IBM supplied interface,
you have another layer of software that possibly could cause what you
are seeing. I'd also check there.
Since this is a production table, I'd assume that recovery logging is
active. If you know approximately when you started the update
(timestamp), you can try using a point-in-time recovery to an offline
database to recover the data that was lost. I've used this on a number
of occasions to fix exactly the same problem you've run into.
Phil Sherman
Ian Boyd wrote:
i accidentally ran an UPDATE statement without the WHERE clause on a
customer's live customers table. After saying "oh shit" many many times, i
closed the ad-hoc query tool, hoping DB2 would see my disconnect and
rollback the implicit transaction. (Either that or DB2 would have completed
the updated before it saw my disconnect).
So, there were two possibilities:
a) 0 row(s) affected
b) 1,398,287 row(s) affected
What actually happened is disturbing, and is my question. When queried to
see how many rows were affected, it was
c) 832,284 row(s) affected
How is it that an aborted UPDATE statement would affect only 60% of the
rows. Using a modern transactional RDMS means that the update was atomic,
and either all rows were affected, or no rows were affected.
So, there are probably three answers that could be posted in response:
a) You must be mistaken; it didn't only affect 60% of the rows.
b) Of course updates in DB2 are not atomic. That would lead to performance
problems that are not acceptable in production environments.
c) Your customer must have set some database option that disables all
transactional integrity. And DB2 has to have this option, becuase otherwise
there could be performance problems that are not acceptable in production
environments.
So pick your answer, or add your own.
Ian
Ian Boyd wrote:
i accidentally ran an UPDATE statement without the WHERE clause on a
customer's live customers table. After saying "oh shit" many many times, i
closed the ad-hoc query tool, hoping DB2 would see my disconnect and
rollback the implicit transaction. (Either that or DB2 would have completed
the updated before it saw my disconnect).
DB2 is transactional and I don't buy the notion of a bug in that space.
Most likely the UPDATE isn't a simple update.
Perhaps a cursor with a commit count to keep logging down?
Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
WAIUG Conference http://www.iiug.org/waiug/present/Fo...Forum2006.html
"Serge Rielau" <sr*****@ca.ibm .comwrote in message
news:4r******** ****@mid.indivi dual.net...
Ian Boyd wrote:
DB2 is transactional and I don't buy the notion of a bug in that space.
Most likely the UPDATE isn't a simple update.
Perhaps a cursor with a commit count to keep logging down?
The statement i ran was:
UPDATE CSPCM
SET SEX@CM='M', DOB@CM=10187, AD1@CM='CENSORE D', CTY@CM='CENSORE D',
ST@@CM='ON', ZIP@CM='CeNsOr' , HDLCCM=390029, TIMCCM=1616, UINCCM='censore d'
On Nov 10, 11:02 am, "Ian Boyd" <ian.msnews...@ avatopia.comwro te:
"Serge Rielau" <srie...@ca.ibm .comwrote in messagenews:4r* ***********@mid .individual.net ...
Ian Boyd wrote:
DB2 is transactional and I don't buy the notion of a bug in that space.
Most likely the UPDATE isn't a simple update.
Perhaps a cursor with a commit count to keep logging down?The statement i ran was:
UPDATE CSPCM
SET SEX@CM='M', DOB@CM=10187, AD1@CM='CENSORE D', CTY@CM='CENSORE D',
ST@@CM='ON', ZIP@CM='CeNsOr' , HDLCCM=390029, TIMCCM=1616, UINCCM='censore d'
Describe the table and indexes and the number of rows. It should be
easy to test/duplicate the problem at IBM... There is no typical
intermediary between a client and the DBMS that will subvert
the SQL you show. Also say which version of DB2 you are running.
Joe
Describe the table and indexes and the number of rows.
Wide table, unknown indexes, ~1.3M rows.
It's not my table, and customer would be....hesitent. ...to talk about it so
soon after 'the incident.'
>Also say which version of DB2 you are running.
Don't know; but it's running on an AS/400, so it's gotta be a million years
old.
... and what client you're using too. Did the SQL run directly on the
server, or via DB2 Connect or Enterprise, or Client Access? I believe
the Client Access driver allows SQL statements (from calling apps) to
run without commitment control, ie it won't necessarily be wrapped in
the notion of a committable transaction. I'm not sure about the others.
I am sure commitment control had to be on to support replication of
AS/400 files using dataPropagator, and I think it's needed for SQL
insert/delete/update from DB2 Connect. SELECT works regardless AFAIK.
If commitment control is off, then you might be stuck with restoring a
backup, or at least comparing backed up data with live to work out which
records to restore..
Ian Boyd wrote:
>>Describe the table and indexes and the number of rows.
Wide table, unknown indexes, ~1.3M rows.
It's not my table, and customer would be....hesitent. ...to talk about it so
soon after 'the incident.'
>>Also say which version of DB2 you are running.
Don't know; but it's running on an AS/400, so it's gotta be a million years
old.
To help w/ this sort of thing, I run a daily cronned script that
unloads/maintains 5 prior ascii versions of critical tables. If
I have an "oh shit" moment, as long as I realize it within 5 days,
I can undo the damage. This has saved my butt a few times.
If you're interested, here's the script. You didn't mention
your OS - mine is Linux. Replace things between <w/ your own.
Cheers
aj
----------------------------------------------------
# This script backs up database tables in ascii format
cd /db2/backups/ascii/<DB>
echo "connect to <DB>;" /db2/backups/ascii/<DB>/backup.sql
echo "set schema <SCHEMA;" >/db2/backups/ascii/<DB>/backup.sql
for table in <LIST YOUR TABLES ON ONE LINE DELIMITED BY A SPACE>
do
if [ -s $table.5.gz ]
then
rm $table.5.gz
fi
if [ -s $table.4.gz ]
then
mv $table.4.gz $table.5.gz
fi
if [ -s $table.3.gz ]
then
mv $table.3.gz $table.4.gz
fi
if [ -s $table.2.gz ]
then
mv $table.2.gz $table.3.gz
fi
if [ -s $table.1.gz ]
then
mv $table.1.gz $table.2.gz
fi
if [ -s $table.txt.gz ]
then
mv $table.txt.gz $table.1.gz
fi
echo $table
done | /usr/bin/awk '
NF == 1 {
printf("EXPORT TO %s.txt OF DEL MODIFIED BY coldel| chardel\"\"
decpt. decplusblank datesiso MESSAGES %s.msg SELECT * FROM <DB>.%s
;\n",$1,$1,$1) ;
}' >/db2/backups/ascii/<DB>/backup.sql
echo "connect reset ;" >/db2/backups/ascii/<DB>/backup.sql
db2 -tvf /db2/backups/ascii/<DB>/backup.sql
#
*************** *************** *************** *************** *************** ******
# Gzip the newly-created .txt's
for file in `ls *.txt`
do
/bin/gzip $file
done
# Note the ending time
echo `date`
Ian Boyd wrote:
i accidentally ran an UPDATE statement without the WHERE clause on a
customer's live customers table. After saying "oh shit" many many times, i
closed the ad-hoc query tool, hoping DB2 would see my disconnect and
rollback the implicit transaction. (Either that or DB2 would have completed
the updated before it saw my disconnect).
So, there were two possibilities:
a) 0 row(s) affected
b) 1,398,287 row(s) affected
What actually happened is disturbing, and is my question. When queried to
see how many rows were affected, it was
c) 832,284 row(s) affected
How is it that an aborted UPDATE statement would affect only 60% of the
rows. Using a modern transactional RDMS means that the update was atomic,
and either all rows were affected, or no rows were affected.
So, there are probably three answers that could be posted in response:
a) You must be mistaken; it didn't only affect 60% of the rows.
b) Of course updates in DB2 are not atomic. That would lead to performance
problems that are not acceptable in production environments.
c) Your customer must have set some database option that disables all
transactional integrity. And DB2 has to have this option, becuase otherwise
there could be performance problems that are not acceptable in production
environments.
So pick your answer, or add your own.
Ian
.. and what client you're using too. Did the SQL run directly on the
server, or via DB2 Connect or Enterprise, or Client Access? I believe the
Client Access driver allows SQL statements (from calling apps) to run
without commitment control, ie it won't necessarily be wrapped in the
notion of a committable transaction. I'm not sure about the others.
I am sure commitment control had to be on to support replication of AS/400
files using dataPropagator, and I think it's needed for SQL
insert/delete/update from DB2 Connect. SELECT works regardless AFAIK.
It was a Windows program called WinSQL. It's speciality is connecting to
an ODBC dsn and run ad-hoc queries. This is useful for us because our
connection to the DB2 database is though a ODBC dsn that the customer
setup for us.
The tool does provide "auto-commit transactions" feature. DB2 implicitly
starts a transaction with most statements, and the tool will automatically
commit it after the statement runs. If you turn the feature off, then you
have
to call COMMIT or ROLLBACK manually.
The important thing here is that i closed the tool before the statement
finished.
And even if it did finish, the database should have commited all the
modifications,
or none of them, not 60% of them.
If commitment control is off, then you might be stuck with restoring a
backup, or at least comparing backed up data with live to work out which
records to restore..
This is a post-mortem. Of all the things that conspired to go wrong,
the very last thing (where my killing the application should have rolled
back the
implicit tranasction) is what i'm trying to explain. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Mark |
last post by:
Hi all,
I have 2 files containing Id numbers and surnames (these files
essentially contain the same data) I want to select distinct() and
join on id number to return a recordset containing every individual
listed in both the files HOWEVER, in some cases an incomplete ID
number has been collected into one of the 2 files -is there a way to...
|
by: Pradeep |
last post by:
Hi,
In the Web application I am working on, data is read from a SQL Server
database. At any time, there are about 15 people browsing the web.
The SQL Server database is updated with new information once every
hour. The update takes a couple of minutes. The isolation level during
the update is so to Serialazable so that the front-end does...
|
by: Richard |
last post by:
hi,
I am using SQL SERVER 2000.
My query is, Can I restore my 60 transactional log file backup
in one sql statement,giving condition where it is suppose to start
and end.
|
by: maricel |
last post by:
I have the following base table structure - DDL:
CREATE TABLE "ADMINISTRATOR"."T1" (
"C1" INTEGER NOT NULL )
IN "TEST_TS" ;
ALTER TABLE "ADMINISTRATOR"."T1"
ADD PRIMARY KEY
|
by: prashant |
last post by:
Hi,
I am trying to set up Transactional replication with immediate
updation.
The configuration is as follows:
1. Publisher is SQL server 2000 Enterprise Edition, and Distributor is
on the same server.
2. Publisher SQL server is installed on Windows 2003.
| |
by: DickChristoph |
last post by:
Hi
I tried posting this query in microsoft.public.sqlserver.programming but got
no response.
I am new to replication but I am trying to setup up a transactional
replication of tables from one database to another in MSSQL 2000 (SP2).
My target tables have primary keys defined. Under publication properties I
go to the snapshot tab and...
|
by: Brian Tkatch |
last post by:
Is there a way to check the order in which SET INTEGRITY needs to be
applied? This would be for a script with a dynamic list of TABLEs.
B.
|
by: Michael Sparks |
last post by:
Hi,
I'm interested in writing a simple, minimalistic, non persistent (at this
stage) software transactional memory (STM) module. The idea being it should
be possible to write such a beast in a way that can be made threadsafe fair
easily.
For those who don't know, STM is a really fancy way of saying variables
with version control (as...
|
by: WTH |
last post by:
I ask because I've got a windows service I've written that manages failover
and replication for our products (or even 3rd party applications) and it
worked great right until I tested it (for ease of testing purposes) with
Internet Explorer (iexplore.exe) - I was testing handling argument list
buffer overflows.
What I found with iexplore.exe...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
|
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. ...
| |
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |