# How to know if there is schema upgrade in ConfD start phase

**URL:** <https://dmap-community.ductus.global/t/how-to-know-if-there-is-schema-upgrade-in-confd-start-phase/963>\
**Category:** General\
**Created:** [January 18, 2017, 7:02am UTC](https://dmap-community.ductus.global/t/how-to-know-if-there-is-schema-upgrade-in-confd-start-phase/963 "2017-01-18T07:02:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![yi\_z\_zhao](https://avatars.discourse-cdn.com/v4/letter/y/45deac/32.png) [@yi\_z\_zhao](https://dmap-community.ductus.global/u/yi_z_zhao)\
**Post date:** [January 18, 2017, 7:02am UTC](https://dmap-community.ductus.global/t/how-to-know-if-there-is-schema-upgrade-in-confd-start-phase/963/1 "2017-01-18T07:02:40Z")

</div>

Hi,

I use external validation callback, and apply the validation in ConfD startup. So I need to wait application to register validation callback after --wait-phase0. But this wait is not needed if CDB exists and there is no schema upgrade when ConfD starts, because ConfD would not invoke validation callback in this case.

So I would like to know which API or other ways can be used to check whether there is schema upgrade in ConfD start phase. Thanks.

---

<div class="post-metadata">

**Author:** ![mnovak](https://yyz2.discourse-cdn.com/flex010/user_avatar/dmap-community.ductus.global/mnovak/32/183_2.png) [@mnovak](https://dmap-community.ductus.global/u/mnovak)\
**Post date:** [January 18, 2017, 10:15am UTC](https://dmap-community.ductus.global/t/how-to-know-if-there-is-schema-upgrade-in-confd-start-phase/963/2 "2017-01-18T10:15:40Z")

</div>

Hello,

please, can you describe your use case in more details?

Why is it problem in your application to wait till ConfD is started in phase1?  
If there is no upgrade (or initial data validation), then the start-up should be fast.  
If there is upgrade, you need to wait anyway.

Maybe you can just use `cdb_wait_start` (from `confd_lib_cdb`) in your application.

Best regards,

Michal

---

<div class="post-metadata">

**Author:** ![cohult](https://yyz2.discourse-cdn.com/flex010/user_avatar/dmap-community.ductus.global/cohult/32/221_2.png) [@cohult](https://dmap-community.ductus.global/u/cohult)\
**Post date:** [January 18, 2017, 1:46pm UTC](https://dmap-community.ductus.global/t/how-to-know-if-there-is-schema-upgrade-in-confd-start-phase/963/3 "2017-01-18T13:46:19Z")

</div>

Use for example cdb\_get\_phase():

$ confd -c ./confd.conf --start-phase0  
$ confd\_cmd -d -d -c get\_phase  
get\_phase  
TRACE Connected (cdb) to ConfD  
TRACE CDB\_GET\_PHASE --\> CONFD\_OK  
phase: 0 flags: 0x2 UPGRADE

Now you know that an upgrade will take place and that the upgrade transaction will modify the data in start-phase 1, so here you can for example save the old data if you wish.

See more in in ConfD 6.3 UG chapter 5.9–5.12.

However, it could be a good thing to register your validation callback in start-phase 0 since a transaction that you want to validate might occur as soon as you move to start-phase 2 since the northbound interfaces are now available.

---

<div class="post-metadata">

**Author:** ![per](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@per](https://dmap-community.ductus.global/u/per)\
**Post date:** [January 18, 2017, 2:12pm UTC](https://dmap-community.ductus.global/t/how-to-know-if-there-is-schema-upgrade-in-confd-start-phase/963/4 "2017-01-18T14:12:17Z")

</div>

> [@cohult](#):
>
> Use for example cdb\_get\_phase():

Yes, but what’s the point with respect to the original question? Just always follow one of the tables in ConfD 6.3 UG “28.5. Starting ConfD”. You will always register in phase0 everything that **may** be needed for the upgrade, if there is one. If there is no upgrade, no harm done, and you have a clear and straightforward startup procedure that you **always** follow, instead of a complex one with conditions and alternatives, making testing harder and errors likely to exist.

---

<div class="post-metadata">

**Author:** ![yi\_z\_zhao](https://avatars.discourse-cdn.com/v4/letter/y/45deac/32.png) [@yi\_z\_zhao](https://dmap-community.ductus.global/u/yi_z_zhao)\
**Post date:** [January 19, 2017, 6:38am UTC](https://dmap-community.ductus.global/t/how-to-know-if-there-is-schema-upgrade-in-confd-start-phase/963/5 "2017-01-19T06:38:31Z")

</div>

In my case, ConfD and the applications that implement the validation callback are started together when the system boot up.

In the case that ConfD validates the configuration in start-phase, i.e. the cdb does not exist, or cdb exists but schema is upgraded, I need to let ConfD wait for a specific time to ensure application is started and register its validation callback to ConfD. The Confd startup sequence is as below.  
confd --start-phase0 [applications may or may not be started at this time. The start of ConfD and application are controlled by one central process controller, which just starts these processes one by one]  
confd --wait-phase0  
start timer (5s) [This step aims to give applications the time to start and to register to confd before confd start-phase1]  
confd --start-phase1

While as ConfD does not validate the configuration in the case that CDB exists and there is no schema upgrade, I need not to let ConfD wait the specific time so that I can speed the confd startup. The ConfD startup sequence is as below.  
confd --start-phase0  
confd --wait-phase0  
confd --start-phase1

Therefore, I want to know if confd is in a schema upgrade phase, and to decide whether need to wait for a specific time or not.

I think the answer from cohult can solve it. Thanks.
