Phase-in of package rebinds

With rebind-phase in, Db2 can rebind a package concurrently with its execution. A rebind operation creates a new copy of the package. When the rebind operation finishes, new threads can use the new package copy immediately, and existing threads can continue to use the copy that was in use prior to the rebind (the phased-out copy) without disruption.

FL 508 With rebind phase-in, a rebind operation generates a new copy, while existing threads continue to execute the current copy of the package, which becomes the phased-out copy. When the new copy is committed by the rebind, that copy becomes the current copy and is immediately available for the next execution by a new thread. Threads that existed prior to the rebind can also use the new current copy when they release the phased-out copy (based on the RELEASE(COMMIT) or RELEASE(DEALLOCATE) options). Start of changeRebind phase-in is supported for packages for SQL PL routines and triggers at function level 508 or higher.End of change

Db2 can generate as many as 14 copies to phase in new package copies at REBIND. Only one is the current copy, and its copy ID is in the catalog table SYSPACKAGE. All phased-out copies, and the original and previous copies, are stored in SYSPACKCOPY and other catalog tables until they are deleted. However, copyID 3 is for internal use only, and is not stored in the SYSPACKCOPY or SYSPACKAGE catalog tables.

On subsequent executions of the REBIND PACKAGE command, Db2 detects when a phased-out copy can be safely deleted, and its copy ID can be reused. The maximum copy ID is 16.

When all available copy IDs are in use, a subsequent REBIND command might fail and issue the DSNT500I message, with reason code 00E30307. This failed command indicates a thread which prevents one or more phased-out copies from being reused.

You can use the PLANMGMTSCOPE(PHASEOUT) option on the FREE PACKAGE subcommand to free unused phased-out copies, which could be created when a package is rebound. It is recommended that phased-out package copies be freed in order to reduce space in the Db2 directory and catalog. The subcommand will free the phased-out copies that are not currently used by an executing thread. The SYSPACKCOPY.TIMESTAMP column value can be used to determine when a copy becomes phased-out. In addition, the PLANMGMTSCOPE(INACTIVE) option on the FREE PACKAGE subcommand also addresses the phased-out copies.

Rebind phase-in is supported with the following options:
  • APREUSE(NONE) PLANMGMT(EXTENDED)
  • APREUSE(WARN) PLANMGMT(EXTENDED) APREUSESOURCE(CURRENT)
  • APREUSE(ERROR) PLANMGMT(EXTENDED) APREUSESOURCE(CURRENT)

Start of changeRebind phase-in is not supported for any command that also specifies changes to any bind options that prevent use of the PLANMGMT(EXTENDED) option. For more information, see PLANMGMT bind option.End of change

Start of changeFL 508 In function level 507 or earlier, the package must not be a generated package for a trigger or SQL routine, such as a procedure or user-defined function. However, this restriction in removed in function level 508 or higher. End of change

When PLANMGMTSCOPE(PHASEOUT) is specified, phased-out package copies are freed regardless of whether the INVALIDONLY(YES) option is also specified.

Start of change

Autobind phase-in

FL 504 Db2 uses autobind phase-in for packages that are marked with statement-level invalidation. Packages with invalid statements can be allocated, and valid statements can execute without waiting for the rebind to complete. However, invalid statements must go through incremental bind before they execute. For more information, see Autobind phase-in for packages with statement-level invalidation and Enabling autobind phase-in for packages invalidated at the statement level.

End of change