why does this new template look so different?• honoring data and business rules in a transactional...

95
A Key to Online Application Upgrade Edition-Based Redefinition

Upload: others

Post on 10-Aug-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

A Key to Online Application UpgradeEdition-Based Redefinition

Page 2: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, timing, and pricing of any features or functionality described for Oracle’s products may change and remains at the sole discretion of Oracle Corporation.

Safe harbor statement

Copyright © 2020, Oracle and/or its affiliates2

Page 3: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Goals of Edition-Based Redefinition

• Allow arbitrary changes to the set of artifacts implementing application’s database of record

• Use both pre-upgrade and post-upgrade application at the same time (hot rollover)

• Maintain uninterrupted availability of the application

• Ensure no noticeable negative impact on performance.

Page 4: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Copyright © 2020, Oracle and/or its affiliates4

The final piece of the HA jigsaw puzzleOnline Application Upgrade

High Availability

SurviveHardware Failure

Planned Software Changes

Change Infrastructure:Operating System, Oracle Database

Change objects’physical properties

Change application’sdatabase objects

Page 5: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

High Availability

SurviveHardware Failure

Planned Software Changes

Change Infrastructure:Operating System, Oracle Database

Change objects’ meaning: patching and upgrading

Change objects’physical properties

Change application’sdatabase objects

Copyright © 2020, Oracle and/or its affiliates5

The final piece of the HA jigsaw puzzleOnline Application Upgrade

Page 6: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Copyright © 2020, Oracle and/or its affiliates6

5

4

3

2

1

Implementation of case study as an EBR exercise

Preparing an application for EBR

Explanation of edition, editioning view, and crossedition trigger

Description of case study

The challenge – and the statement of the solution

Program agenda

Demo6

Page 7: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Online Application Upgrade

• Supporting online application upgrade requires maintaining uninterrupted availability of the application

• End-user sessions can last tens of minutes or longer because –

• Users of the old app don’t want to abandon an ongoing session• Users wanting to start a session must use the new app, but cannot wait until no-one is

using the old app

• Thus, there is requirement for using both the pre-upgrade application and the post-upgrade application at the same time – a.k.a. hot rollover

Page 8: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

The challenge

• Upgrading production database without disturbing live users of the pre-upgrade application

• Making changes to database objects in privacy

• Ensuring transactions done by the users of the pre-upgrade application are reflected in the post-upgrade application

• Achieving hot rollover i.e., transactions done by the users of the post-upgrade application are reflected in the pre-upgrade application.

Page 9: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Functional goals of any ZDT solution

• Cloning V[n] database into V[n+1] database

• Making arbitrary changes in V[n+1] database without them showing up in V[n] database

• Syncing data between V[n] and V[n+1] databases when all intended changes are done in the V[n+1] database.

• Ensuring V[n] database is in sync with V[n+1] database, when V[n+1] is opened for use

• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization

Page 10: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Non-functional goals of any ZDT solution

• Creating V[n+1] as a clone of V[n] instantaneously without taking additional space.

• It must have no noticeable effect on the performance experience of the online users

• This implies that the solution must work its magic by making one single database seem, to connecting clients, as if it’s two separate databases

• This, of course, is how EBR works

Page 11: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Copyright © 2020, Oracle and/or its affiliates11

Edition• Code changes are installed in the privacy of a new edition• Data changes are made safely by writing to new columns/tables• These changes are not seen by the old edition

Editioning View• Exposes a different projection of a table into each edition • Allows each user to see just its own columns

Cross edition Trigger• Propagates data changes made by the old edition into the new edition’s columns• Also, propagates changes made by new edition into old edition’s columns in the case of hot-

rollover

Key Features of Edition-Based Redefinition

Page 12: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Copyright © 2020, Oracle and/or its affiliates12

Hot rollover across stack - General Upgrade

Runedition

Run app

Traffic Director

Page 13: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Copyright © 2020, Oracle and/or its affiliates13

Hot rollover across the stack

Runedition

Run app

Traffic Director

Page 14: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Copyright © 2020, Oracle and/or its affiliates14

Hot rollover across the stack

Runedition

Run app

Traffic Director

Page 15: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Copyright © 2020, Oracle and/or its affiliates15

Hot rollover across the stack

Runedition

Run app

Traffic Director

Page 16: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Copyright © 2020, Oracle and/or its affiliates16

Hot rollover across the stack – Normal use (pre-upgrade)

Runedition

Run app

Traffic Director

Page 17: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Copyright © 2020, Oracle and/or its affiliates17

Hot rollover across the stack – Upgrade begins

Runedition

Run app

Patchedition

Traffic Director

Page 18: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Copyright © 2020, Oracle and/or its affiliates18

Hot rollover across the stack – Upgrade complete

Runedition

Run app Patch app

Traffic Director

Patchedition

Page 19: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Copyright © 2020, Oracle and/or its affiliates19

Hot rollover across the stack

Runedition

Run app

Traffic Director

Patchedition

Patch app

Page 20: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Copyright © 2020, Oracle and/or its affiliates20

Hot rollover across the stack – Hot rollover begins!

Runedition

Run app

Traffic Director

Patchedition

Patch app

Page 21: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Copyright © 2020, Oracle and/or its affiliates21

Hot rollover across the stack

Runedition

Run app

Traffic Director

Patchedition

Patch app

Page 22: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Copyright © 2020, Oracle and/or its affiliates22

Hot rollover across the stack

Runedition

Run app

Traffic Director

Patchedition

Patch app

Page 23: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Copyright © 2020, Oracle and/or its affiliates23

Hot rollover across the stack

Runedition

Run app

Traffic Director

Patchedition

Patch app

Page 24: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Copyright © 2020, Oracle and/or its affiliates24

Hot rollover across the stack

Runedition

Run app

Traffic Director

Patchedition

Patch app

Page 25: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Copyright © 2020, Oracle and/or its affiliates25

Hot rollover across the stack

Runedition

Run app

Traffic Director

Patchedition

Patch app

Page 26: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Copyright © 2020, Oracle and/or its affiliates26

Hot rollover across the stack – hot rollover ends!

Former Run app

Traffic Director

Runedition

Run app

FormerRun edition

Page 27: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Copyright © 2020, Oracle and/or its affiliates27

Hot rollover across the stack – normal use (post-upgrade)

Traffic Director

Run edition

Run appFormer Run app

FormerRun edition

Page 28: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Copyright © 2020, Oracle and/or its affiliates28

Hot rollover across the stack – cleanup

Traffic Director

Run edition

Run app

FormerRun edition

Page 29: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Copyright © 2020, Oracle and/or its affiliates29

Hot rollover across the stack

Traffic Director

Run edition

Run app

Page 30: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Copyright © 2020, Oracle and/or its affiliates30

Case Study

Page 31: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Copyright © 2020, Oracle and/or its affiliates31

Scenario – for now think only about synonyms, views, and PL/SQL

• The application has 1,000 mutually dependent code objects

• In general, there’s more than one schema

• They refer to each other by name – in general, by schema- qualified name

• The upgrade needs to change 10 of these

The edition – setting the stage

Page 32: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Copyright © 2020, Oracle and/or its affiliates32

The edition – setting the stage

1,000 v1 objects

990 unchanged v1 objects+

10 changed v2 objects

Pre-upgrade application backend

Post-upgrade application backend

Page 33: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Copyright © 2020, Oracle and/or its affiliates33

• You can’t change the 10 objects in place as it would change the pre-upgrade app• An old and a new occurrence of the “same” object cannot co-exist• Before EBR, the only dimensions that determine which object you mean, when one

object refers to another, are its name and its owner• In short, the naming mechanisms, historically, were not rich enough to support online

application upgrade

The edition – setting the stage

Page 34: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Copyright © 2020, Oracle and/or its affiliates34

• EBR introduces the new nonschema object type, edition – each edition can have its own private occurrence of “the same” object

• A database must have at least one edition• You create a new edition as the child of an existing edition – and an edition can’t have

more than one child• A database session specifies which edition to use (of course, the database has a default

edition)

The edition extends the naming mechanism

Page 35: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Copyright © 2020, Oracle and/or its affiliates35

• An object is identified by its name and its owner• An editioned object is identified by its name, its owner, and the edition where it was

created• However, when you identify it you can mention only its name and owner. This reference is

interpreted in the context of a current edition- in SQL execution- in the text of a stored object

The edition extends the naming mechanism

Page 36: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Copyright © 2020, Oracle and/or its affiliates36

When you create a new edition, every editioned objectin the parent edition is copied into the new edition

The semantic model for “create edition”

Page 37: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Copyright © 2020, Oracle and/or its affiliates37

The mental model of the implementation

Object_1

Object_2

Object_3

Object_4

Pre-upgrade edition

Page 38: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Copyright © 2020, Oracle and/or its affiliates38

The mental model of the implementation

Pre-upgrade edition Post-upgrade edition

Object_1

Object_2

Object_3

Object_4

Object_1

Object_2

Object_3

Object_4

is child of

(inherited)

(inherited)

(inherited)

(inherited)

Page 39: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Copyright © 2020, Oracle and/or its affiliates39

The mental model of the implementation

Pre-upgrade edition Post-upgrade edition

Object_1

Object_2

Object_3

Object_4

Object_1*

Object_2*

Object_3

Object_4

is child of

(actual)

(actual)

(inherited)

(inherited)

Page 40: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Copyright © 2020, Oracle and/or its affiliates40

The mental model of the implementation

Pre-upgrade edition Post-upgrade edition

Object_1

Object_2

Object_3

Object_4

Object_1*

Object_2*

Object_3

Object_4

is child ofPre-upgrade edition

(dropped)

(actual)

(inherited)

(inherited)

Page 41: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Copyright © 2020, Oracle and/or its affiliates41

• If your upgrade needs only to change synonyms, views, or PL/SQL units, you now have all the tools you need

• Simply run the scripts that you, anyway, have written using a new edition while the application stays online

• Then change the default edition and let new session start in the new edition

• No “package state discarded” errors ever again!

Editions

Page 42: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Copyright © 2020, Oracle and/or its affiliates42

1. Not all object types are editionable• Synonyms, views, and PL/SQL units of all kinds (including, therefore, triggers and

libraries), and are editionable• Objects of all other object types – for example tables – are noneditionable

2. You need to version the structure of a table manually• Instead of changing a column, you add a replacement column• Then you rely on the fact that a view is editionable

Editionable and noneditionable object types

Page 43: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Copyright © 2020, Oracle and/or its affiliates43

• An editioning view (EV) may only project and rename columns• You can’t have more than one editioning view for a table in a particular edition• The EV must be owned by the table’s owner• Application code should refer only to the logical world• You can create table-style triggers (before or after statement or each row) on an

editioning view using the “logical” column names• A SQL optimizer hint can request an index on the physical table by specifying the

“logical” column names• Like all views, an editioning view can be read-only

Editioning views

Page 44: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Copyright © 2020, Oracle and/or its affiliates44

• Any SQL statement that refers to one, or several, EVs will get the same execution plan as the statement you’d get if you replaced each of those references, by hand, with a reference to the table that the EV covers

• So using an EV in front of every table brings no performance consequences

• Tests have proved this

Editioning views – performance

Page 45: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Copyright © 2020, Oracle and/or its affiliates45

• An object whose type is noneditionable is never editioned• An object whose type is editionable is editioned only when you request it for that

object (requires that the owner is editions-enabled)• You control the editioned state at the granularity of the single name• Theorem (the NE-on-E prohibition): a noneditioned object cannot ordinarily depend

on an editioned object- For example, a table cannot depend on an editioned UDT- If you want to use a type as the datatype for a column, that UDT must not be editioned

Editioned and noneditioned objects – slight return

Page 46: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Copyright © 2020, Oracle and/or its affiliates46

These objects have metadata that is explicitly set by the create and alter statements

• The evaluation edition explicitly specifies the name of the edition in which the resolution of editioned names will be done

- within the closure of the object’s static dependency parents (at compile time)- and for those objects that are identified dynamically during SQL execution (at run time)

• The usable edition range explicitly specifies the set of adjacent editions within which the optimizer will consider the object, for query re-write, when computing the execution plan

Materialized views and indexes on virtual columns

Page 47: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Copyright © 2020, Oracle and/or its affiliates47

• A public synonym is just a synonym that happens to be owned by the Oracle-maintained user called “public”

• “public” user is editions enabled, but all existing public synonyms are non-editioned at the per-object level

• You can now make your own public synonyms editioned at the per-object level

Public synonyms

Page 48: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Copyright © 2020, Oracle and/or its affiliates48

• An ordinary column (as opposed to virtual) cannot specify the evaluation edition or the usable edition range metadata

• Therefore, a UDT that defines the datatype for a table column must remain noneditioned

• In an EBR exercise, if the aim is to redefine the UDT, then the “classic” replacement column paradigm is used

Tables with UDT columns

Page 49: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Copyright © 2020, Oracle and/or its affiliates49

• Of course, DML does not stop during online application upgrade

• If the upgrade needs to change the structure that stores transactional data – like the orders customers make using an online shopping site – then the installation of values into the replacement columns must keep pace with these changes

• Triggers have the ideal properties to do this safely

• Each trigger must fire appropriately to propagate changes made to pre-upgrade columns into the post- upgrade columns – and vice versa

The crossedition trigger

Page 50: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Copyright © 2020, Oracle and/or its affiliates50

• Crossedition triggers directly access the table

• They have special firing rules

• You create crossedition triggers in the Post_Upgrade edition- The paradigm is: don’t do any DDLs in the Pre_Upgrade edition

• The firing rules rules assume that- Pre-upgrade columns are changed only by sessions using the Pre_Upgrade edition- Post-upgrade columns are changed only by sessions using the Post_Upgrade edition

The crossedition trigger

Page 51: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Copyright © 2020, Oracle and/or its affiliates51

• A forward crossedition trigger is fired by application DML issued by sessions using the Pre_Upgrade edition

• A reverse crossedition trigger is fired by application DML issued by sessions using the Post_Upgrade edition

The crossedition trigger

Page 52: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Copyright © 2020, Oracle and/or its affiliates52

• Put an editioning view in front of every table- The EV and the table it covers can’t have the same name- Rename each table to an obscure but related name (e.g. append an underscore, or lowercase

the name)- Create an editioning view for each table that has the same name that the table originally had

• NOTE:- If a schema has an object, whose type is noneditionable, that depends on an object whose type

is editionable, then the adoption plan must accommodate this by controlling the editioned state of objects whose type is editionable, at the granularity of the individual object

- Else, the editioned state can be conveniently set for the whole schema

Readying the application for editions

Page 53: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Copyright © 2020, Oracle and/or its affiliates53

• Revoke privileges from the tables and grant them to the editioning views• Move VPD policies to the editioning views• “Move” triggers to the editioning views

- Just drop the trigger and re-run the original (or mechanically edited) create trigger statement to recreate it on the editioning view

• Of course- All indexes on the original Employees table remain valid but User_Ind_Columns now shows the

new values for Table_Name and Column_Name- All constraints (foreign key and so on) on the original Employees remain in force for Employees_

• This readying work must be done by the developers of the application that adopts EBR

Readying the application for editions

Page 54: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Case study

Copyright © 2020, Oracle and/or its affiliates54

Page 55: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

PK Phone ...

Employees_

Run edition

Employees Maintain_Emps

Copyright © 2020, Oracle and/or its affiliates55

Page 56: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

PK Phone ...

Employees_

Employees Maintain_Emps

Employees Maintain_Emps

Run edition

Patch edition

Copyright © 2020, Oracle and/or its affiliates56

Page 57: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Employees Maintain_Emps

Employees Maintain_Emps

PK Phone #Cntry...

Employees_

Run edition

Patch edition

Copyright © 2020, Oracle and/or its affiliates57

Page 58: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Employees Maintain_Emps

PK Phone #Cntry...

Employees_

Employees Maintain_Emps

Run edition

Patch edition

Copyright © 2020, Oracle and/or its affiliates58

Page 59: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Employees Maintain_Emps

PK Phone #Cntry...

Employees_

Employees Maintain_Emps

Fwd_Xed

Run edition

Patch edition

Copyright © 2020, Oracle and/or its affiliates59

Page 60: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Employees Maintain_Emps

PK Phone #Cntry...

Employees_

Employees Maintain_Emps

Fwd_Xed

Run edition

Patch edition

Copyright © 2020, Oracle and/or its affiliates60

Page 61: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Employees Maintain_Emps

PK Phone #Cntry...

Employees_

Employees Maintain_Emps

Fwd_Xed Rvrs_Xed

Run edition

Patch edition

Copyright © 2020, Oracle and/or its affiliates61

Page 62: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Employees Maintain_Emps

PK Phone #Cntry...

Employees_

Employees Maintain_Emps

Fwd_Xed Rvrs_Xed

presentRun edition

to-beRun edition

Copyright © 2020, Oracle and/or its affiliates62

Page 63: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Employees Maintain_Emps

PK Phone #Cntry...

Employees_

Employees Maintain_Emps

formerRun edition

Run edition

Copyright © 2020, Oracle and/or its affiliates63

Page 64: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

PK Phone #Cntry...

Employees_

Employees Maintain_Emps

formerRun edition

Run edition

Copyright © 2020, Oracle and/or its affiliates64

Page 65: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

PK Phone #Cntry...

Employees_

Employees Maintain_Emps

Run edition

Copyright © 2020, Oracle and/or its affiliates65

Page 66: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

PK Phone #Cntry...

Employees_

Employees Maintain_Emps

Run edition

Copyright © 2020, Oracle and/or its affiliates66

Page 67: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Copyright © 2020, Oracle and/or its affiliates67

• “Drop edition” is re-implemented to formalize retiring an edition• You can always drop the root edition, even when it contains actual editioned objects

that are inherited by a descendent edition• It remains in place, but it is marked “unusable” so that you can never use it again• An editioned object in an unusable edition that is not visible in a usable edition is

dropped safely and automatically by a background process• When an unusable edition contains no actual editioned objects, it is dropped safely

and automatically by a background process

Automated retiring of unused editions in Oracle Database 12.2

Page 68: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Rolling backa failed EBR exercise

Page 69: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Employees Maintain_Emps

PK Phone #Cntry...

Employees_

Employees Maintain_Emps

Fwd_Xed Rvrs_Xed

Run edition

Patch edition

Copyright © 2020, Oracle and/or its affiliates69

Page 70: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Employees Maintain_Emps

PK Phone #Cntry...

Employees_

Employees Maintain_Emps

Fwd_Xed Rvrs_Xed

Run edition

Patch edition

Copyright © 2020, Oracle and/or its affiliates70

Page 71: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Employees Maintain_Emps

PK Phone #Cntry...

Employees_

Run edition

Copyright © 2020, Oracle and/or its affiliates71

Page 72: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Copyright © 2020, Oracle and/or its affiliates72

Column widening using the replacement column paradigm

Demonstration

Page 73: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

create edition e1 as child of Ora$Base/

alter session set edition = e1/

Insensitive to pending DML

Copyright © 2020, Oracle and/or its affiliates73

Page 74: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

alter table t_ add c_Wide varchar2(50)/

Waits on pending DML without blocking new DML

Copyright © 2020, Oracle and/or its affiliates74

Page 75: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

create trigger Fwdbefore update or insert on t_ for each rowforward crosseditiondisable

begin:New.c_Wide := :new.c;

end Fwd;/

alter trigger Fwd enable/

Insensitive to pending DML

Copyright © 2020, Oracle and/or its affiliates75

Page 76: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

declare-- Supplying "null" for the SCN formal to Wait_On_Pending_DML()-- asks it to get the most current SCN across all instances.SCN number := null;

-- A null or negative value for Timeout will cause a very long wait.Timeout constant integer := null;

beginif not Sys.DBMS_Utility.Wait_On_Pending_DML(Tables => 't_',Timeout => Timeout,SCN => SCN)

thenRaise_Application_Error(-20000,'Wait_On_Pending_DML() timed out. '||'CET was enabled before SCN: '||SCN);

end if;end Wait_On_Pending_DML;/

Deliberately wait on pending DML. Doesn’t block new DML.

Copyright © 2020, Oracle and/or its affiliates76

Page 77: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

declareCur integer :=Sys.DBMS_Sql.Open_Cursor(Security_Level => 2);

No_Of_Updated_Rows integer not null := -1;beginSys.DBMS_Sql.Parse(c => Cur,Language_Flag => Sys.DBMS_Sql.Native,Statement => 'update t_ set c = c',Apply_Crossedition_Trigger => 'Fwd',Fire_Apply_Trigger => true);

No_Of_Updated_Rows := Sys.DBMS_Sql.Execute(Cur);

Sys.DBMS_Sql.Close_cursor(Cur);end;/

Apply the crossedition trigger’s transform to every row

Copyright © 2020, Oracle and/or its affiliates77

Page 78: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

alter table t_modify c_Wide constraint t_c_Wide_NN not nullenable novalidate/

Waits on pending DML without blocking new DML

Copyright © 2020, Oracle and/or its affiliates78

Page 79: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

create unique index t_c_Wide_Unqon t_(c_Wide)online/

Waits on pending DML without blocking new DML

Copyright © 2020, Oracle and/or its affiliates79

Page 80: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

alter table t_add constraint t_c_Wide_Unq unique (c_Wide)using index t_c_Wide_Unqenable novalidate/

Waits on pending DML without blocking new DML

Copyright © 2020, Oracle and/or its affiliates80

Page 81: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

alter table t_enable validateconstraint t_c_Wide_NN/

alter table t_enable validateconstraint t_c_Wide_Unq/

create or replace editioning view t asselect PK, c_Wide c from t_/

Insensitive to pending DML

Copyright © 2020, Oracle and/or its affiliates81

Page 82: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

create trigger Rvrsbefore update or insert on t_ for each rowreverse crosseditiondisable

begin:New.c := :new.c_Wide;

end Rvrs;/

alter trigger Rvrs enable/

Insensitive to pending DML

Hot rollover can start now!

Copyright © 2020, Oracle and/or its affiliates82

Page 83: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Wait until no sessions are using the old edition.

Then retire it.

Copyright © 2020, Oracle and/or its affiliates83

Page 84: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

alter database default edition = e1/

Insensitive to pending DML

Copyright © 2020, Oracle and/or its affiliates84

Page 85: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

-- Want to drop the crossedition triggers ASAP-- to avoid now-unnecessary cost of firing them.-- Must first drop the constraint that Revrs satisfies.

alter table t_drop constraint t_c_NNonline/

Waits on pending DML without blocking new DML

Copyright © 2020, Oracle and/or its affiliates85

Page 86: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

alter trigger Rvrs disable/drop trigger Rvrs/

alter trigger Fwd disable/drop trigger Fwd/

Insensitive to pending DML

Copyright © 2020, Oracle and/or its affiliates86

Page 87: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

alter table t_drop constraint t_c_Unqonline/

Waits on pending DML without blocking new DML

Copyright © 2020, Oracle and/or its affiliates87

Page 88: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

-- Drop all covered objects.-- Normally this is done entirely mechanically by discovering the-- covered objects and generating the appropriate "drop" for each.

declareStmt constant varchar2(32767) not null := 'drop view t';

Cur integer :=Sys.DBMS_Sql.Open_Cursor(Security_level=>2);

begin-- Parse for a DDL implies Execute.Sys.DBMS_Sql.Parse(c => Cur,Language_Flag => Sys.DBMS_Sql.Native,Statement => Stmt,Edition => 'ORA$BASE');

Sys.DBMS_Sql.Close_Cursor(Cur);end;/

Insensitive to pending DML

Copyright © 2020, Oracle and/or its affiliates88

Page 89: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Copyright © 2020, Oracle and/or its affiliates89

alter table t_set unused column conline/

The EBR exercise is now complete!

Waits on pending DML without blocking new DML

Page 90: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Copyright © 2020, Oracle and/or its affiliates90

EBR brings the edition, the editioning view, and the crossedition trigger

• Code changes are installed in the privacy of a new edition

• Data changes are made safely by writing only to new columns or new tables not seen by the old edition

• An editioning view exposes a different projection of a table into each edition to allow each to see just its own columns

• A crossedition trigger propagates data changes made by the old edition into the new edition’s columns, or (in hot- rollover) vice-versa

Edition-Based Redefinition

Page 91: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Copyright © 2020, Oracle and/or its affiliates91

• Some table DDLs that used to fail if another session had outstanding DML now always succeed

• Others, that cannot succeed while there’s outstanding DML, are now governed by a timeout parameter

• Online index creation and rebuild now never cause other sessions to wait

• The dependency model is now fine-grained: e.g. adding a new column to a table, or a new subprogram to a package spec, no longer invalidates the dependants

Evolutionary capability improvements

Page 92: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Copyright © 2020, Oracle and/or its affiliates92

• Online application upgrade is a high availability subgoal• Traditionally, HA goals are met by features that the administrator can choose to use at the

site of the deployed application- independently of the design of the application- without the knowledge of the application “vendor”

• The features for online application upgrade are used by the application “vendor”- when preparing the application for EBR- when implementing an EBR exercise

• Site administrators, of course, will need to understand the features

Nota bene

Page 93: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Copyright © 2020, Oracle and/or its affiliates93

• Read the edition-based redefinition chapter in the Oracle Database Development Guide

• Read EBR whitepaper, published on oracle.com/ebr

Next steps

Page 94: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional

Copyright © 2020, Oracle and/or its affiliates94

Thank you

Page 95: Why does this new template look so different?• Honoring data and business rules in a transactional fashion—in the presence of this mutual bi-directional synchronization Non-functional