300 likes | 316 Views
Discover how to make code and table changes in an Oracle database without impacting users. Learn strategies for changing code while the database is active, handling complex scenarios, dependencies, and more. Explore tips to avoid unnecessary invalidations and optimize database performance. This session with David Webster provides insights for managing and releasing database changes effectively.
E N D
Hot or Not?How to Release Changes Without Impacting Customers David Webster April 2014
What this session is about? • How do we make code and table changes to an Oracle database without impacting any of the users? • How do we do that even on a really complex database with 1000s of users/sessions?
What is this session about, specifically? • Why put code in the DB? • How to change that code while the DB is active. • Under what circumstances is that challenging? (24x7, high executions, daemons, DB Links, dependencies) • What can we do about it? • ELEPHANT IN THE ROOM : EDITIONS
Just before I start…. • All tests are on 11.2.0.3 • HOT or NOT…. • Hot doesn’t mean hot, cold doesn’t mean cold
ABOUT BETFAIR • Pioneered online person-to-person betting. Betfair is the broker, the eBay of betting, not the “house” • Company started in 1999 with 2 founders • over 1500 employees across the world • Data centres across Europe, in Australia and US • full offering of betting products, including Sportsbook, Poker, Casino and Arcade.
About David Webster • 15 years working with Oracle • Site Reliability Engineer – Oracle performance • Blog : http://anotherdavewebster.wordpress.com/
Why put code in the database? • Centralised logic and versioning (I know…) • PL/SQL APIs. Abstraction and encapsulation • Performance • Dependency tracking • Others……
Why should I not put code in the database? • Performance….. • DIGRESSION ALERT!!! • PREFETCH & Read Consistency • Makes releasing code more difficult!
What makes OUR exchange a complex db? It’s 4 databases Over 100k executions a second 1000s of sessions, 100s of clients Lots and lots of code Background jobs 24x7 operation
(RE)Compiling packages Q : what does oracle need to compile a package body? A : Oracle requires an exclusive lock on the object Q : DOES ANYTHING GET invalidated WHEN I COMPILE A BODY? A : NO Q : What about a package spec? A : Compiling a package spec invalidates calling bodies* Q : Is my (re)compilation limited to the code that I change? A : NO….. Compile only what you need AVOID INVALIDATING PACKAGES
Getting the lock • Stop background jobs • Need a window 60 50 10 40 0 20 30 Minute
Package state • What is package state? ORA-04068: existing state of packages has been discarded
Package state • ConsTants • CONSTANT workaround ORA-04068: existing state of packages has been discarded
Unnecessary invalidations : FGDT • Fine Grained dependency tracking
Unnecessary invalidations : FGDT • NOT Needed • Needed
Changing Package Specifications • Changing the package specification invalidates all calling packages • Except that’s not true
Changing Package Specifications • END means after the last referenced procedure! To be safe, add to the very end
Left with a mess? When overloading, refactor internally If you can’t delete, throw an error Do a cold release
DATABASE Links Don’t use them Session-tastic Confuse the poor CBO Don’t use them Edge cases and complexity
DATABASE Links fixed user database link CONNECTED USER Database LINK
Database links RED_TIGER RED_TIGER RED_SCOTT BLUE_SCOTT Package PACKAGE reads BLUE_SCOTT.TABLE@BLUE TABLE GRANT EXECUTE ON PACKAGE TO RED_TIGER GRANT SELECT ON TABLE TO RED_SCOTT GRANT SELECT ON TABLE TO RED_TIGER RED_SCOTT Bug 13415892 - UNNECESSARY INVALIDATION OF REMOTE STUBS
SUMMARY • To compile (or recompile) a package, you need an exclusive lock • Package state limits options • MINIMISE UNECESSARY COMPILATION • SCOPE PL/SQL VARIABLES • MODIFY SPECIFICATION CAREFULLY • Beware database links
Thank you Q&A David.Webster@betfair.com