<!-- 
RSS generated by JIRA (9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b) at Mon Feb 12 10:02:59 CET 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>Magnolia - Issue tracker</title>
    <link>https://jira.magnolia-cms.com</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-uk</language>    <build-info>
        <version>9.4.2</version>
        <build-number>940002</build-number>
        <build-date>19-01-2023</build-date>
    </build-info>


<item>
            <title>[MGNLHOOK-307] Random problem reading environments on module startup</title>
                <link>https://jira.magnolia-cms.com/browse/MGNLHOOK-307</link>
                <project id="17487" key="MGNLHOOK">Magnolia Webhooks</project>
                    <description>&lt;h2&gt;&lt;a name=&quot;Symptom&quot;&gt;&lt;/a&gt;Symptom&lt;/h2&gt;

&lt;p&gt;Webhook events are not triggered on environments different than&#160;&lt;b&gt;main&lt;/b&gt;, even if the definitions appear on Definitions App.&lt;/p&gt;
&lt;h2&gt;&lt;a name=&quot;Cause&quot;&gt;&lt;/a&gt;Cause&lt;/h2&gt;

&lt;p&gt;Sometimes on SaaS webapp (staging), after instance is restarted, this code:&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;
environmentsClient
                    .getEnvironmentNames()
                    .forEach(environmentId -&amp;gt; EnvironmentContextPerThread.runInEnvironmentContext(environmentId, webhookDefinitionRegistry::onUpdate)); &lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;on Webhooks module startup, is only executed for&#160;&lt;b&gt;main&lt;/b&gt; environment,&#160;&lt;b&gt;but&lt;/b&gt; all environments are shown on Environment Switcher&#160;&lt;b&gt;and&lt;/b&gt;&#160;Definitions app shows properly all webhook definition files by environment.&lt;/p&gt;

&lt;p&gt;As other environments than&#160;&lt;b&gt;main&lt;/b&gt;, are loaded asynchronously, when module starts up, definitions are not there and subscribers can not be created for webhooks. But later, those definitions are finally loaded, and appear properly on Definitions App (but subscribers still does not exist, because there were no events on webhooks telling that the definitions were loaded, so subscribers weren&apos;t created).&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;</description>
                <environment></environment>
        <key id="124022">MGNLHOOK-307</key>
            <summary>Random problem reading environments on module startup</summary>
                <type id="1" iconUrl="https://jira.magnolia-cms.com/secure/viewavatar?size=xsmall&amp;avatarId=10883&amp;avatarType=issuetype">Bug</type>
                                            <priority id="6" iconUrl="https://jira.magnolia-cms.com/images/icons/priorities/neutral.gif">Neutral</priority>
                        <status id="6" iconUrl="https://jira.magnolia-cms.com/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are not closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="1">Fixed</resolution>
                                        <assignee username="mdivilek">Milan Divilek</assignee>
                                    <reporter username="jbenito">Javier Benito</reporter>
                        <labels>
                    </labels>
                <created>Thu, 15 Dec 2022 10:19:06 +0100</created>
                <updated>Wed, 1 Feb 2023 03:48:40 +0100</updated>
                            <resolved>Wed, 1 Feb 2023 03:48:40 +0100</resolved>
                                    <version>2.0.0</version>
                                                        <due></due>
                            <votes>0</votes>
                                    <watches>3</watches>
                                                                    <aggregateprogress percentage="100">
                                    <originalProgress>
                                                    <row percentage="0" backgroundColor="#89afd7"/>
                                                    <row percentage="100" backgroundColor="transparent"/>
                                            </originalProgress>
                                                    <currentProgress>
                                                    <row percentage="100" backgroundColor="#51a825"/>
                                                    <row percentage="0" backgroundColor="#ec8e00"/>
                                            </currentProgress>
                            </aggregateprogress>
                                                                                                    <aggregatetimespent seconds="10800">3h</aggregatetimespent>
                                    <comments>
                            <comment id="339298" author="mdivilek" created="Fri, 20 Jan 2023 16:19:39 +0100"  >&lt;h2&gt;&lt;a name=&quot;TestedSolutions&quot;&gt;&lt;/a&gt;Tested Solutions &lt;/h2&gt;

&lt;h3&gt;&lt;a name=&quot;Problem&quot;&gt;&lt;/a&gt;Problem&lt;/h3&gt;
&lt;p&gt;I tested 3 possible solutions (Event via EventBus, Callback, subscriber lazyloading), but all have problem with &lt;b&gt;&quot;MgnlContext is not set&quot;&lt;/b&gt; exception when &lt;tt&gt;info.magnolia.webhooks.registry.WebhookDefinitionEventHandler#createSubscriberFor&lt;/tt&gt; creates &lt;tt&gt;info.magnolia.webhooks.events.core.EventSubscriber&lt;/tt&gt; because &lt;b&gt;it&apos;s running in different thread where MgnlContext is not set.&lt;/b&gt;&lt;br/&gt;
This can be workaround by using SystemContext for creating &lt;tt&gt;info.magnolia.webhooks.events.core.EventSubscriber&lt;/tt&gt;. This should be safe as we are not manipulating with any data.&lt;/p&gt;

&lt;h4&gt;&lt;a name=&quot;%22environmentdefinitionsloaded%22callback&quot;&gt;&lt;/a&gt;&quot;environment definitions loaded&quot; callback&lt;/h4&gt;
&lt;p&gt;Unfortunately &lt;tt&gt;info.magnolia.config.source.ConfigurationSource&lt;/tt&gt; doesn&apos;t support any callback and {EnvironmentBoundConfigurationSource}} is build via &lt;tt&gt;info.magnolia.config.plugin.S3ConfigurationSourcePlugin&lt;/tt&gt;. This means for using callback we would need to do several API changes in &lt;tt&gt;info.magnolia.config.source.ConfigurationSource&lt;/tt&gt; , &lt;tt&gt;info.magnolia.config.source.ConfigurationSourcePlugin&lt;/tt&gt;, etc. Even it doesn&apos;t seems right to have defined callback for Environment related stuff in interfaces which doesn&apos;t know nothing about Environments.&lt;/p&gt;

&lt;h4&gt;&lt;a name=&quot;UsingEventBusandfiringeventwhenloadingenvironmentiscomplete.&quot;&gt;&lt;/a&gt;Using EventBus and firing event when loading environment is complete.&lt;/h4&gt;
&lt;p&gt;Firing &lt;tt&gt;EnvironmentConfigurationLoadedEvent&lt;/tt&gt; when environment is loaded &lt;a href=&quot;https://git.magnolia-cms.com/projects/CLOUD/repos/magnolia-cloud/browse/saas-config/src/main/java/info/magnolia/config/source/contextual/EnvironmentBoundConfigurationSource.java#133&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;here&lt;/a&gt; in &lt;tt&gt;#whenComplete&lt;/tt&gt; clause. Disadvantage of this solution is that we are trying to minimalisite using of EventBus.&lt;/p&gt;

&lt;h4&gt;&lt;a name=&quot;Initsubscriberswhenfirstwebhookeventisfired%28lazyloading%29&quot;&gt;&lt;/a&gt;Init subscribers when first webhook event is fired (lazyloading)&lt;/h4&gt;
&lt;p&gt;Init &lt;tt&gt;info.magnolia.webhooks.events.core.EventSubscriber&lt;/tt&gt; first time when &lt;tt&gt;info.magnolia.webhooks.events.core.EventSubscribers&lt;/tt&gt; is called. This suffers also from the &quot;MgnlContext is not set&quot; problem, because webhook events are also triggered in different thread.&lt;/p&gt;

&lt;h2&gt;&lt;a name=&quot;Mainissue&quot;&gt;&lt;/a&gt;Main issue&lt;/h2&gt;
&lt;p&gt;Main issue here is in CLOUD-742, where we changed starting Environments to async. This may cause that that the environment/definitions are not ready when module starts. All the tested solutions above fixes the webhook module, but in case other modules needs defintions to be available at the start up, there&apos;s going to be same issue(which is hard to find).&lt;/p&gt;</comment>
                            <comment id="339372" author="czimmermann" created="Mon, 23 Jan 2023 09:55:01 +0100"  >&lt;p&gt;Regarding the &quot;Main Issue&quot; above:&lt;/p&gt;

&lt;p&gt;Is there something special about Webhooks that makes this issue more relevant for them? Or put another waay - is there a reason this issue has been reported against webhooks vs another definition type - such as restEndpoints? Is there another definition type that &quot;needs definitions to be available at the startup&quot;? or conversely - Why does webhooks need the definitions available at startup?&lt;/p&gt;

&lt;p&gt;Concretely, which other definitions might still cause problems? All of them? For example:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;templates&lt;/li&gt;
	&lt;li&gt;contentTypes&lt;/li&gt;
	&lt;li&gt;apps&lt;/li&gt;
	&lt;li&gt;restEndpoionts&lt;/li&gt;
	&lt;li&gt;...&lt;/li&gt;
&lt;/ul&gt;
</comment>
                            <comment id="340497" author="czimmermann" created="Mon, 30 Jan 2023 09:25:08 +0100"  >&lt;p&gt;Thanks. OK. Well my 2cts would be that webhooks needing to fire during system startup is an edgecase and I would prefer not to support it at all if it would make the system more stable or easier to maintain.&#160;&lt;br/&gt;
But we don&apos;t need to change anything about that now - ie &lt;a href=&quot;https://jira.magnolia-cms.com/secure/ViewProfile.jspa?name=mdivilek&quot; class=&quot;user-hover&quot; rel=&quot;mdivilek&quot;&gt;mdivilek&lt;/a&gt;&#160;can continue with current fix. (Unless you folks want to discuss it further &lt;a href=&quot;https://jira.magnolia-cms.com/secure/ViewProfile.jspa?name=jsimak&quot; class=&quot;user-hover&quot; rel=&quot;jsimak&quot;&gt;jsimak&lt;/a&gt; &lt;a href=&quot;https://jira.magnolia-cms.com/secure/ViewProfile.jspa?name=jbenito&quot; class=&quot;user-hover&quot; rel=&quot;jbenito&quot;&gt;jbenito&lt;/a&gt;&#160;)&lt;/p&gt;</comment>
                            <comment id="340582" author="JIRAUSER22310" created="Mon, 30 Jan 2023 12:44:47 +0100"  >&lt;p&gt;I&apos;d say the current solution is ok, is working now.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10360">
                    <name>Problem/Incident</name>
                                                                <inwardlinks description="is caused by">
                                                        </inwardlinks>
                                    </issuelinktype>
                            <issuelinktype id="10160">
                    <name>Relates</name>
                                                                <inwardlinks description="relates to">
                                        <issuelink>
            <issuekey id="123944">MGNLHOOK-309</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                            <subtask id="124857">MGNLHOOK-314</subtask>
                            <subtask id="124858">MGNLHOOK-315</subtask>
                            <subtask id="124859">MGNLHOOK-316</subtask>
                            <subtask id="124860">MGNLHOOK-317</subtask>
                    </subtasks>
                <customfields>
                                                                            <customfield id="customfield_14166" key="com.okapya.jira.checklist:checklist">
                        <customfieldname>Acceptance criteria</customfieldname>
                        <customfieldvalues>
                            
        <checklist>
        <![CDATA[
                            




                
                                    <div class="o-completion" style="display: flex; flex-shrink: 0;"><span  class="aui-lozenge aui-lozenge-complete" style="font-size: 12px; font-weight: normal; display: flex; flex-direction: row; align-items: center;" ><span style="padding-right: 4px; vertical-align: middle;"><svg width="15" height="15" viewBox="0 0 15 15" xmlns="http://www.w3.org/2000/svg" fill="white"><path clip-rule="evenodd" d="m10.41037,3.42544l-7.86501,0c-0.72395,0 -1.31084,0.58688 -1.31084,1.31084l0,7.86508c0,0.7239 0.58689,1.3108 1.31084,1.3108l7.86501,0c0.724,0 1.3109,-0.5869 1.3109,-1.3108l0,-7.86508c0,-0.72396 -0.5869,-1.31084 -1.3109,-1.31084zm-7.86501,-0.65542c-1.08593,0 -1.96626,0.88032 -1.96626,1.96626l0,7.86508c0,1.0859 0.88033,1.9662 1.96626,1.9662l7.86501,0c1.086,0 1.9663,-0.8803 1.9663,-1.9662l0,-7.86508c0,-1.08594 -0.8803,-1.96626 -1.9663,-1.96626l-7.86501,0z" fill-rule="evenodd"/><path d="m5.09049,10.18526l-1.82767,-1.82766l-0.78479,0.78479l2.61246,2.61246l5.38758,-5.38754l-0.78483,-0.78479l-4.60275,4.60274z"/></svg></span><span>Empty</span></span></div>
                        ]]>
    </checklist>


                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_10111" key="com.atlassian.jira.toolkit:reporterdomain">
                        <customfieldname>Company</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>magnolia-cms.com</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_10031" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of First Response</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Fri, 20 Jan 2023 16:19:39 +0100</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_12730" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_14151" key="com.atlassian.jira.toolkit:message">
                        <customfieldname>Docu info</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                            <customfield id="customfield_10246" key="com.pyxis.greenhopper.jira:gh-epic-link">
                        <customfieldname>Epic Link</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>MGNLHOOK-10</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_10061" key="com.atlassian.jira.toolkit:lastusercommented">
                        <customfieldname>Last comm is not jira-dev</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>true</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10071" key="com.atlassian.jira.toolkit:lastupdaterorcommenter">
                        <customfieldname>Last participant</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>oanh.thai</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_13136" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            1 year, 1 week, 6 days ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                            <customfield id="customfield_10020" key="com.atlassian.jira.toolkit:attachments">
                        <customfieldname>Number of attachments</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>0.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10150" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname>Number of comments</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>4.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_10011" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>czimmermann</customfieldvalue>
            <customfieldvalue>jbenito</customfieldvalue>
            <customfieldvalue>mdivilek</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                    <customfield id="customfield_10833" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>0|hzztx1:1yccw1a100i00901ii34</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10244" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>9223372036854775807</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_10245" key="com.pyxis.greenhopper.jira:gh-sprint">
                        <customfieldname>Sprint</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue id="1745">DevX 28</customfieldvalue>
    <customfieldvalue id="1755">DevX 29</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_10242" key="com.atlassian.jira.plugin.system.customfieldtypes:float">
                        <customfieldname>Story Points</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>5.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_12430" key="com.atlassian.teams:rm-teams-custom-field-team">
                        <customfieldname>Team</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue><![CDATA[26]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_14145" key="com.intenso.jira.issue-templates:issue-templates-customfield">
                        <customfieldname>Template</customfieldname>
                        <customfieldvalues>
                            


                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_15131" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Time in Discovery</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>68</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10032" key="com.atlassian.jira.ext.charting:timeinstatus">
                        <customfieldname>Time in Status</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                            <customfield id="customfield_13933" key="com.atlassian.jira.plugin.system.customfieldtypes:select">
                        <customfieldname>Urgency (resolution)</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="15724"><![CDATA[Normal]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_14630" key="com.atlassian.jira.plugin.system.customfieldtypes:datetime">
                        <customfieldname>Work Started</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Tue, 20 Dec 2022 12:46:27 +0100</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                    </customfields>
    </item>
</channel>
</rss>