function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
MJ09MJ09 

Upgrading a managed package while an Apex class is scheduled to run

I have a managed package that includes a schedulable Apex class. As part of the post-package-installation instructions, the customer schedules that class to run on a nightly basis.

 

I also have an unmanaged version of this package, developed in a completely separate org, that I have deployed via the IDE to a few test orgs. If the Apex job is scheduled in the target org, the deployment fails, because it won't allow me to deploy a new version of the Apex class while the previous version is still scheduled to execute. I have to unschedule the job, then deploy, and then re-schedule the new version of the class.

 

With the managed package, I was surprised to discover that I can install a new version of the package into an org in which the previous version was already installed, even if the previous version of the Apex class is still scheduled to execute. This behavior of the managed package upgrade process seems different from the behavior of the unmanaged deployment process.

 

What IS the expected behavior when I install an upgrade to a managed package, when a class for that package is already scheduled to execute? Should the upgrade fail? If it shouldn't fail (it doesn't), what version of the code will run the next time the scheduled job runs -- the original version or the upgraded version?

JerryHJerryH

> With the managed package, I was surprised to discover that I can install a new version

> of the package into an org in which the previous version was already installed, even if

> the previous version of the Apex class is still scheduled to execute.

 

Is this a recent policy change of some sort?  The last time I tried to do a push upgrade of a managed package installation it would fail if the package was scheduled -- which is why I'm searching the SF forums now, to see if there is a solution.

 

So (if I'm understanding your post correctly) I *should* be able to do a push upgrade on a managed package even if it's scheduled?  If that's the case, then what am I doing wrong?

 

Thanks!

 

Jerry H.