Ask me later about…
Transcription
Ask me later about…
How to Upgrade Your Application with no Downtime (and no Additional Costs!) Oren Nakdimon www.db-oriented.com [email protected] +972-54-4393763 @DBoriented First of all, let’s gather some statistics… © Oren Nakdimon This presentation is available in http://db-oriented.com/presentations A QUICK SURVEY (1/4) Do you know what Edition Based Redefinition is? © Oren Nakdimon This presentation is available in http://db-oriented.com/presentations A QUICK SURVEY (2/4) Have you ever used Edition Based Redefinition in production? © Oren Nakdimon This presentation is available in http://db-oriented.com/presentations A QUICK SURVEY (3/4) Which Oracle versions do you use (or plan to use) in production? 12c 11g R2 11g R1 or earlier © Oren Nakdimon This presentation is available in http://db-oriented.com/presentations A QUICK SURVEY (4/4) Which Oracle editions do you use (or plan to use) in production? Standard Edition Enterprise Edition © Oren Nakdimon This presentation is available in http://db-oriented.com/presentations WHO AM I? A CHRONOLOGY BY “ORACLE YEARS” Where: IAF When: Oracle 6/7 [1991-1997] Where: Golden Screens What: Developer When: Oracle 8 [1997-1998] What: Server Group Manager Where: TELEknowledge When: Oracle 8i/9i [1998-2003] What: DBA Group Manager Where: Olista When: Oracle 10g/11g [2004-2011] What: VP R&D + Israel Site Manager Where: Where: When: Oracle 11g/12c [2011-] When: 2015- What: What: Freelance Consultant Database Expert © Oren Nakdimon This presentation is available in http://db-oriented.com/presentations @DBORIENTED © Oren Nakdimon This presentation is available in http://db-oriented.com/presentations HTTP://DB-ORIENTED.COM © Oren Nakdimon This presentation is available in http://db-oriented.com/presentations SHARING EXPERIENCE FROM… A 24x7 system Millions of end-users Thousands of concurrent end-users All around the world Lots of PL/SQL code Frequent upgrades Intensive use of EBR © Oren Nakdimon This presentation is available in http://db-oriented.com/presentations THE BOTTOM LINE I think EBR is great! It is quite a big and complex feature, but… It is very easy to start using it It may take some time to know all the details and nuances Warning: as with any other feature, make sure to test it thoroughly before you decide to apply it in production Ask me later about… Issues that are out of the presentation’s scope © Oren Nakdimon This presentation is available in http://db-oriented.com/presentations AGENDA Application upgrades Scenarios Methods EBR introduction Upgrade use cases Requirements Challenges with online upgrade Solving with EBR Tips © Oren Nakdimon This presentation is available in http://db-oriented.com/presentations APPLICATION UPGRADES Scenarios APPLICATION UPGRADES Application X Application X + some change(s) © Oren Nakdimon This presentation is available in http://db-oriented.com/presentations APPLICATION UPGRADES © Oren Nakdimon This presentation is available in http://db-oriented.com/presentations APPLICATION UPGRADES Upgrades are inherent to every application lifecycle They may be: Small or big Frequent or rare Simple or complex With or without schema changes Introducing new functionality, changing existing functionality, or removing functionality © Oren Nakdimon This presentation is available in http://db-oriented.com/presentations APPLICATION UPGRADES Methods EDITION-BASED REDEFINITION Introduction EDITION BASED REDEFINITION EBR is a feature set that lets you upgrade the database component of an application while it is in use, thereby minimizing or eliminating downtime Introduced EBR in 11gR2 is supported in all editions, and requires no special license © Oren Nakdimon This presentation is available in http://db-oriented.com/presentations EDITION BASED REDEFINITION The fundamental ability is that different copies of the same object may coexist Not all objects are editionable TOM JERRY Edition1 PKG_A MY_VIEW Edition2 PKG_A MY_VIEW TABLE_X TABLE_Y PKG_A MY_OBJ MY_OBJ © Oren Nakdimon This presentation is available in http://db-oriented.com/presentations EDITIONS Edition is a non-schema object There must be at least one edition in the database The initial edition is ORA$BASE There is always one database-level default edition © Oren Nakdimon This presentation is available in http://db-oriented.com/presentations EDITIONS – CONT. Every new edition is created as a child of an existing edition (11.2, 12.1), each edition may have at most one child edition Edition1 Currently Edition2 Ask me later about… Enabling editions to users Granting use on editions Edition3b Edition3 © Oren Nakdimon This presentation is available in http://db-oriented.com/presentations UPGRADE USE CASES APP_MGR (package) do_something PEOPLE_DL (package) add | remove PEOPLE (table) © Oren Nakdimon This presentation is available in http://db-oriented.com/presentations APP_MGR S PEOPLE_DL B @people_setup S B Table © Oren Nakdimon This presentation is available in http://db-oriented.com/presentations USE CASE 1 – THE REQUIREMENTS A package body should be changed No change in package spec No change in table structure © Oren Nakdimon This presentation is available in http://db-oriented.com/presentations USE CASE 1 – THE CHALLENGES Blocking Compilation is blocked by active clients Clients are blocked during compilation © Oren Nakdimon This presentation is available in http://db-oriented.com/presentations Tip © Oren Nakdimon This presentation is available in http://db-oriented.com/presentations SESSION EDITION Each The To session uses one edition at a time current session edition: SHOW EDITION (SQL*Plus) SYS_CONTEXT(‘userenv’,’session_edition_name’) change the session edition: ALTER SESSION SET EDITION = edition; Must be the first statement of a transaction © Oren Nakdimon This presentation is available in http://db-oriented.com/presentations EDITIONED OBJECTS An editioned object in an edition is either: Inherited p or edition1 Actual Note: edition2 actualization is irreversible! p @end_user_session @use_case_1 edition3 © Oren Nakdimon This presentation is available in http://db-oriented.com/presentations APP_MGR ora$base V1 S PEOPLE_DL B S B B Table © Oren Nakdimon This presentation is available in http://db-oriented.com/presentations USE CASE 2 – THE REQUIREMENTS A package spec should be changed No change in table structure APP_MGR ora$base V1 S PEOPLE_DL B S B B Table © Oren Nakdimon This presentation is available in http://db-oriented.com/presentations USE CASE 2 – THE CHALLENGES Invalidation Compilation errors (hopefully not…) Object dependency Revalidation occurs automatically when an object is referenced Multiple interrelated objects need to be changed APP_MGR S PEOPLE_DL B S B Table © Oren Nakdimon This presentation is available in http://db-oriented.com/presentations USE CASE 2 A package spec should be changed No change in table structure APP_MGR ora$base S PEOPLE_DL B S B B V1 Table V2 S © Oren Nakdimon This presentation is available in http://db-oriented.com/presentations USE CASE 2 A package spec should be changed No change in table structure APP_MGR ora$base S PEOPLE_DL B S B B V1 Table V2 S © Oren Nakdimon This presentation is available in http://db-oriented.com/presentations A VERY IMPORTANT FOOTNOTE Source: http://www.oracle.com/technetwork/database/features/availabilit y/ebr-455513.html © Oren Nakdimon This presentation is available in http://db-oriented.com/presentations Tip Ask me later about… How to identify dependent objects Different ways to actualize © Oren Nakdimon This presentation is available in http://db-oriented.com/presentations USE CASE 3 – THE REQUIREMENTS A new column should be added It represents a new logic An existing package should be changed accordingly © Oren Nakdimon This presentation is available in http://db-oriented.com/presentations USE CASE 3 – THE CHALLENGES Invalidation Code dependent on the table is invalidated (!) APP_MGR ora$base S PEOPLE_DL B S B V1 V2 B B S B Table © Oren Nakdimon This presentation is available in http://db-oriented.com/presentations ELIMINATING INVALIDATION Program Unit View Table © Oren Nakdimon This presentation is available in http://db-oriented.com/presentations EDITIONING VIEWS Editioning Views are: Views (hence editionable) Deliberately limited: One per table May contain only the SELECT and FROM clauses The FROM clause refers to a single table The SELECT list may contain only columns and aliases (no expressions) DML triggers can be defined on them © Oren Nakdimon This presentation is available in http://db-oriented.com/presentations Editioning Views are the Interface between the Application and the Tables © Oren Nakdimon This presentation is available in http://db-oriented.com/presentations Tip Ask me later about… Other schema changes that cause invalidations And how to handle them @use_case_3 © Oren Nakdimon This presentation is available in http://db-oriented.com/presentations Tip © Oren Nakdimon This presentation is available in http://db-oriented.com/presentations USE CASE 4 – THE REQUIREMENTS A new column should be added It replaces an existing column Cutover @use_case_4 © Oren Nakdimon This presentation is available in http://db-oriented.com/presentations USE CASE 4 – THE CHALLENGES Keeping the old representation and new representation in sync until the cutover © Oren Nakdimon This presentation is available in http://db-oriented.com/presentations CROSSEDITION TRIGGERS A crossedition trigger is a “bridge” for moving data between editions Temporary in nature Forward crossedition triggers transform preupgrade representation to post-upgrade representation @fce_trigger © Oren Nakdimon This presentation is available in http://db-oriented.com/presentations Tip Ask me later about… Mass update of the data © Oren Nakdimon This presentation is available in http://db-oriented.com/presentations Tip © Oren Nakdimon This presentation is available in http://db-oriented.com/presentations USE CASE 5 A new column should be added It replaces an existing column Rollover © Oren Nakdimon This presentation is available in http://db-oriented.com/presentations REVERSE CROSSEDITION TRIGGERS Reverse crossedition triggers transform postupgrade representation to pre-upgrade representation @rce_trigger © Oren Nakdimon This presentation is available in http://db-oriented.com/presentations Tip © Oren Nakdimon This presentation is available in http://db-oriented.com/presentations EXPOSING THE NEW VERSION Database-level: ALTER DATABASE DEFAULT EDITION = edition; Session level Statement level – using DBMS_SQL.PARSE Service level Ask me later about… ORA-04068 After Logon trigger © Oren Nakdimon This presentation is available in http://db-oriented.com/presentations Ask me later about… Retiring editions Dropping editions What’s new in 12c Jobs and editions DB links and editions Whatever you like… © Oren Nakdimon This presentation is available in http://db-oriented.com/presentations THANK YOU Oren Nakdimon www.db-oriented.com [email protected] +972-54-4393763 @DBoriented