Thursday, May 22, 2014

MAR deployment lifecycle

ADF application shipped with MAR file automatically deploys meta-information to associated MDS - details are described in article "JEE application and MDS provisioning". This document focus on MAR deployment's life cycle and related records written into MDS database.


#1 One of SOA deployments left following error in the log file:

<SEVERE: An Exception occured during the pre-deploy label creation: preDeployLabel_soa-config-wls
oracle.mds.versioning.LabelExistsException: MDS-01906: A label with same name preDeployLabel_soa-config-wls already exists.

Short investigation uncovered a way how SOA designers solved the problem of MAR provisioning in multimode environment.

#2 MDS uses two tables to store status of MAR deployment: MDS_LABELS, and MDS_DEPL_LINEAGES. The former keeps technical information about deployments and the latter is more informative keeping information about application and mar file. The MDS_LABELS is critical. Documentation explains what a metadata label is: 

"A metadata label is a means of selecting a particular version of each object from a metadata repository partition. Conceptually, it is a collection of document versions, one version per document, representing a horizontal stripe through the various document versions. This stripe comprises the document versions which were the tip versions (latest versions) at the time the label was created." [Link

#3 MDS_LABEL contains rows with post deployment information identified by "postDeployLabel_" prefix, app name, mar file name, and MAR checksum in the suffix. e.g. postDeployLabel_soa-infra_soa.mar_3680241450. This label is used to recognize meta information packages already deployed; in case of EAR redeployment MDS will be not populated as all elements of the label are the same. 

<NOTIFICATION: Querying checksum data from target repository to avoid transferring unchanged documents.> 
<NOTIFICATION: Query to get the checksum of the documents from target repository completed successfully.> 
<NOTIFICATION: deploy with CHANGED restriction operation started.> 
<NOTIFICATION: deploy with CHANGED restriction is completed. Total number of documents successfully processed : 4, total number of documents failed : 0.> 
<INFO:  Transfered size = 4> 
<INFO: The Metadata Archive (MAR) "soa-config.mar" for application "soa-config-2v0" was successfully deployed.> 

It's possible that the same EAR with updated meta information will be redeployed. In such case, EAR checksum will be different, thus deployment will proceed. By using file checksums (MDS_PATHS.PATH_CONT_CHECKSUM) MDS deployer will recognize which files were changes, transferring only updated ones.

<NOTIFICATION: Querying checksum data from target repository to avoid transferring unchanged documents.>
<NOTIFICATION: Query to get the checksum of the documents from target repository completed successfully.> 
<NOTIFICATION: deploy with CHANGED restriction operation started.> 
<NOTIFICATION: deploy with CHANGED restriction is completed. Total number of documents successfully processed : 1, total number of documents failed : 0.> 
<INFO:  Transfered size = 4> 
<INFO: The Metadata Archive (MAR) "soa-config.mar" for application "soa-config-1v0" was successfully deployed.> 

In this situation one of files will be versioned by MDS. Let me quote documentation:

"Versioning: A database-based MDS Repository maintains versions of the documents in a database-based repository. Versioning allows changes to metadata objects to be stored as separate versions rather than simply overwriting the existing data in the metadata repository. It provides version history, as well as the ability to label versions so that you can access the set of metadata as it was at a given point in time." [Link]

It was verified that SOA Suite picks up latest version of soa-infra-config.xml. 

#4. MDS_LABELS keeps temporary information about deployment process. This element is critical for "singleton" style deployment. Pre deployment label is build out of "preDeployLabel_" prefix, and the app name. No checksum, and no mar information is here. In case of concurrent deployment system will recognize existing preDeployLabel and MAR deployment will be skipped.

<SEVERE: An Exception occured during the pre-deploy label creation: preDeployLabel_soa-config-2v0
oracle.mds.versioning.LabelExistsException: MDS-01906: A label with same name preDeployLabel_soa-config-2v0 already exists.
(...)
<INFO: The Metadata Archive (MAR) deployment is already in progress for the application: "soa-config-2v0". The pre-deployment label is "preDeployLabel_soa-config-2v0". Skipping MAR deployment.> 

Criticism
1. Different EAR packages may access the same MDS. There is no meta information access protection other than database credentials.  On one hand it looks bad, but on the other one MDS stores just meta information not a business data. This is generally public information. 
2. MDS sharing works for both read and write. It's possible that one of application will overwrite meta information of the other one.

###

Appendix. Simulate broken or parallel deployment

declare
  partitionNo integer;
begin

  select max(partition_id) into partitionNo from mds_partitions;

  INSERT INTO "MDS_LABELS" 
      (LABEL_PARTITION_ID, LABEL_NAME, LABEL_DESCR, LABEL_CN, ENTERPRISE_ID) 
  VALUES 
      (partitionNo, 'preDeployLabel_soa-config-wls', 'Deploy Label', -1, 0);

end;

Appendix. Audit MAR lifecycle

DROP TABLE "DEV_MDS"."MDS_AUDIT" 
CREATE TABLE "DEV_MDS"."MDS_AUDIT" 
   (
"LABEL_PARTITION_ID" NUMBER, 
"LABEL_NAME" VARCHAR2(1000 BYTE), 
"LABEL_DESCR" VARCHAR2(800 BYTE), 
"LABEL_CN" NUMBER, 
"LABEL_TIME" TIMESTAMP (6), 
"ENTERPRISE_ID" NUMBER(18,0) DEFAULT NVL(SYS_CONTEXT('CLIENTCONTEXT', 'MDS_MT_TENANT_ID'), 0),
changeTime TIMESTAMP (6) DEFAULT (sysdate)
   );
CREATE OR REPLACE TRIGGER "DEV_MDS"."TRIGGER1" 
AFTER INSERT OR UPDATE ON DEV_MDS.MDS_LABELS for each row
BEGIN
  insert into DEV_MDS.mds_audit(ENTERPRISE_ID,LABEL_CN,LABEL_DESCR,LABEL_NAME,LABEL_PARTITION_ID,LABEL_TIME) 
  values (:new.ENTERPRISE_ID,:new.LABEL_CN,:new.LABEL_DESCR,:new.LABEL_NAME,:new.LABEL_PARTITION_ID,:new.LABEL_TIME);
END;
/
ALTER TRIGGER "DEV_MDS"."TRIGGER1" ENABLE;


Appendix. Stack trace from concurrent deployment of MAR

<SEVERE: An Exception occured during the pre-deploy label creation: preDeployLabel_soa-config-wls
oracle.mds.versioning.LabelExistsException: MDS-01906: A label with same name preDeployLabel_soa-config-wls already exists.
at oracle.mds.persistence.PTransactionVSupportImpl.createLabel(PTransactionVSupportImpl.java:159)
at oracle.mds.versioning.VersionHelper.createLabel(VersionHelper.java:294)
at oracle.mds.internal.lcm.deploy.labels.DBLabel.createLabel(DBLabel.java:237)
at oracle.mds.internal.lcm.deploy.labels.DBLabel.create(DBLabel.java:168)
at oracle.mds.internal.lcm.deploy.DeployManager.createPreDeployLabel(DeployManager.java:1369)
at oracle.mds.internal.lcm.deploy.DeployManager.deploy(DeployManager.java:678)
at oracle.mds.internal.lcm.deploy.DeployManager.startDeployment(DeployManager.java:211)
at oracle.mds.internal.lcm.MDSLifecycleListenerImpl.start(MDSLifecycleListenerImpl.java:215)
at oracle.mds.lcm.weblogic.WLLifecycleListener.preStart(WLLifecycleListener.java:77)
at weblogic.application.internal.flow.BaseLifecycleFlow$PreStartAction.run(BaseLifecycleFlow.java:282)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.application.internal.flow.BaseLifecycleFlow$LifecycleListenerAction.invoke(BaseLifecycleFlow.java:199)
at weblogic.application.internal.flow.BaseLifecycleFlow.preStart(BaseLifecycleFlow.java:62)
at weblogic.application.internal.flow.HeadLifecycleFlow.prepare(HeadLifecycleFlow.java:283)
at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:648)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:191)
at weblogic.application.internal.EarDeployment.prepare(EarDeployment.java:59)
at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:154)
at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:60)
at weblogic.deploy.internal.targetserver.operations.RedeployOperation.createAndPrepareContainer(RedeployOperation.java:104)
at weblogic.deploy.internal.targetserver.operations.RedeployOperation.doPrepare(RedeployOperation.java:128)
at weblogic.deploy.internal.targetserver.operations.AbstractOperation.prepare(AbstractOperation.java:217)
at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentPrepare(DeploymentManager.java:747)
at weblogic.deploy.internal.targetserver.DeploymentManager.prepareDeploymentList(DeploymentManager.java:1216)
at weblogic.deploy.internal.targetserver.DeploymentManager.handlePrepare(DeploymentManager.java:250)
at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.prepare(DeploymentServiceDispatcher.java:159)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doPrepareCallback(DeploymentReceiverCallbackDeliverer.java:171)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$000(DeploymentReceiverCallbackDeliverer.java:13)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$1.run(DeploymentReceiverCallbackDeliverer.java:46)
at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:545)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)> 
<INFO: The Metadata Archive (MAR) deployment is already in progress for the application: "soa-config-wls". The pre-deployment label is "preDeployLabel_soa-config-wls". Skipping MAR deployment.


Appendix. Log prefix of MAR deployer

<NOTIFICATION: Customization layer "adfshare" from MDS Component Config in mds-config.xml has been merged with the customization layers defined in persistence-config of the applications adf-config.xml file.>
<NOTIFICATION: PManager instance is created without multitenancy support as JVM flag "oracle.multitenant.enabled" is not set to enable multitenancy support.>
<NOTIFICATION: Customization layer "adfshare" from MDS Component Config in mds-config.xml has been merged with the customization layers defined in persistence-config of the applications adf-config.xml file.>
<NOTIFICATION: PManager instance is created without multitenancy support as JVM flag "oracle.multitenant.enabled" is not set to enable multitenancy support.>

###


No comments:

Post a Comment