Discussions
Categories
- 197K All Categories
- 2.5K Data
- 546 Big Data Appliance
- 1.9K Data Science
- 450.8K Databases
- 221.9K General Database Discussions
- 3.8K Java and JavaScript in the Database
- 31 Multilingual Engine
- 552 MySQL Community Space
- 479 NoSQL Database
- 7.9K Oracle Database Express Edition (XE)
- 3.1K ORDS, SODA & JSON in the Database
- 556 SQLcl
- 4K SQL Developer Data Modeler
- 187.2K SQL & PL/SQL
- 21.4K SQL Developer
- 296.4K Development
- 17 Developer Projects
- 139 Programming Languages
- 293.1K Development Tools
- 110 DevOps
- 3.1K QA/Testing
- 646.1K Java
- 28 Java Learning Subscription
- 37K Database Connectivity
- 161 Java Community Process
- 105 Java 25
- 22.1K Java APIs
- 138.2K Java Development Tools
- 165.3K Java EE (Java Enterprise Edition)
- 19 Java Essentials
- 162 Java 8 Questions
- 86K Java Programming
- 81 Java Puzzle Ball
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 94.3K Java SE
- 13.8K Java Security
- 205 Java User Groups
- 24 JavaScript - Nashorn
- Programs
- 475 LiveLabs
- 39 Workshops
- 10.2K Software
- 6.7K Berkeley DB Family
- 3.5K JHeadstart
- 5.7K Other Languages
- 2.3K Chinese
- 175 Deutsche Oracle Community
- 1.1K Español
- 1.9K Japanese
- 233 Portuguese
Replacing / Compiling Database Triggers in a HA/High Load system

Ronnie_in_Craigavon
Member Posts: 25 Blue Ribbon
Hi there,
My collegue has just asked me if downtime needs to be scheduled to replace an After IUD Database trigger where I've made a minor change.
If this were a package or procedure, the answer would be an obvious yes, as I'd be wary of my users getting the dreaded: ORA-04068... State of Package has been disguarded.
What about when working with database triggers?
If the trigger is firing at the same time that I perform my Create or Replace Trigger DDL, will everything fall into a screaming heap?
Notes:
Oracle 10g R2 db.
High DML rates on the table that the After IUD Trigger is 'attached' to.
It's a near certainty that when the Create or Replace Trigger DDL runs, the trigger will be active at the time.
The Trigger is 'simple' in that it's use: is to call a DB package with some of the :new values as params.
+(I'm happy to rtfm - if someone can tell me where!!)+
Cheers -
Ron Marks
My collegue has just asked me if downtime needs to be scheduled to replace an After IUD Database trigger where I've made a minor change.
If this were a package or procedure, the answer would be an obvious yes, as I'd be wary of my users getting the dreaded: ORA-04068... State of Package has been disguarded.
What about when working with database triggers?
If the trigger is firing at the same time that I perform my Create or Replace Trigger DDL, will everything fall into a screaming heap?
Notes:
Oracle 10g R2 db.
High DML rates on the table that the After IUD Trigger is 'attached' to.
It's a near certainty that when the Create or Replace Trigger DDL runs, the trigger will be active at the time.
The Trigger is 'simple' in that it's use: is to call a DB package with some of the :new values as params.
+(I'm happy to rtfm - if someone can tell me where!!)+
Cheers -
Ron Marks
Tagged:
Answers
-
Hello,
I'm not sure that it is necessary but how about to lock your table before you recreate your trigger and release after that...
If you have a test system you may able to test if this works...
HTH. Regards, Zoltan -
Hi Zoltan,
Locking the entire table (for the two seconds that it would take to recompile this trigger) was an option that I thought of as well, however, I initially discounted it: as I cannot guarantee that some transactions on the table involved won't fail with an ORA-00054 (...nowait specified.)
(As I write this, I'm looking through dba_source to see how many select for update clauses are present with the nowait clause)
It however may be the option that we go with at the time of night with the lowest DML count on the table involved.
Thanks for the help though.
Ronnie. -
If this were a package or procedure, the answer would be an obvious yes, as I'd be wary of my users getting the dreaded: ORA-04068... State of Package has been disguarded.Not true. This exception is thrown only if sessions have some state represented in package variables. If there is no associated session state, then no exception would be thrown after recompile.If the trigger is firing at the same time that I perform my Create or Replace Trigger DDL, will everything fall into a screaming heap?You'll wait - to lock an object in library cache which represents your trigger. Not sure if this would require a library cache lock on underlying table, but I would guess that it is required. BTW, locking a table would make no any sense: CREATE TRIGGER is a DDL, which means before it began it issues a COMMIT => all locks are released, and it is quite possible that a TM lock for CREATE TRIGGER won't be acquired since resource would be busy.
Oracle 11gR2 claims to address problems of application upgrades on a high-load environments with a feature called "Editions" (not a good name - try to find something about it via Google...) -
A simple test shows that the trigger re-compile will wait (enqueue) until the trigger is idle, ie, not firing.
The world does not end, and there is no error, well, not in my tests anyway.
1) create a normal empty table to place in some test data.
2) create a trigger that will upon firing, do something that will take a long time (a minute or more); ie, insert a million rows into your test data.
3) create a small anon pl/sql block that will fire your trigger several times in quick succession, ie, do an insert, and update... whatever.
4) Run your pl/sql block... This will then run for several minutes.
5) In a seperate window at the same time that your pl/sql block is running, re-compile your trigger with a small change.
Result:
The TRigger re-compile will wait until the trigger has stopped firing, even if that means that it has to wait several minutes.
If someone else can verify that the result is always an enqueue, I'll consider this question answered.
Ron. -
Thanks Timur,
Your answer that the trigger re-compile will wait, confirms what I found in my test.
Thanks for your help, and experience.
Ron.
This discussion has been closed.