<!-- 
RSS generated by JIRA (1001.0.0-SNAPSHOT#100246-sha1:7a5c50119eb0633d306e14180817ddef5e80c75d) at Thu Feb 08 23:24:14 UTC 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 add field=key&field=summary to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>FOLIO Jira</title>
    <link>https://folio-org.atlassian.net</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>1001.0.0-SNAPSHOT</version>
        <build-number>100246</build-number>
        <build-date>07-02-2024</build-date>
    </build-info>

<item>
            <title>[FOLIO-2919] Try out optimistic locking with real module and document steps</title>
                <link>https://folio-org.atlassian.net/browse/FOLIO-2919</link>
                <project id="10290" key="FOLIO">FOLIO</project>
                    <description>&lt;p&gt;&lt;a href=&quot;https://folio-org.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3Ab8e64633-1f7c-402d-9caf-9959a5ba5d0d&quot; class=&quot;user-hover&quot; rel=&quot;557058:b8e64633-1f7c-402d-9caf-9959a5ba5d0d&quot; data-account-id=&quot;557058:b8e64633-1f7c-402d-9caf-9959a5ba5d0d&quot; accountid=&quot;557058:b8e64633-1f7c-402d-9caf-9959a5ba5d0d&quot; rel=&quot;noreferrer&quot;&gt;Jakub Skoczen&lt;/a&gt; brought up the idea that we should test the recent optimistic locking change with a real module, for example, update a table in mod-inventory-storage to see if anything is broken. The test should be done locally, and there will be no code changes to merge back to source control.&lt;/p&gt;</description>
                <environment></environment>
        <key id="81920">FOLIO-2919</key>
            <summary>Try out optimistic locking with real module and document steps</summary>
                <type id="10003" iconUrl="https://folio-org.atlassian.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10318?size=medium">Task</type>
                                            <priority id="10001" iconUrl="https://dev.folio.org/assets/jira-priority/jira-p2.svg">P2</priority>
                        <status id="6" iconUrl="https://folio-org.atlassian.net/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="green"/>
                                    <resolution id="10003">Done</resolution>
                                                        <assignee accountid="557058:4f6bed01-40a6-48d5-8471-7ef21f5ea97c">Hongwei Ji</assignee>
                                                                <reporter accountid="557058:4f6bed01-40a6-48d5-8471-7ef21f5ea97c">Hongwei Ji</reporter>
                                    <labels>
                            <label>platform-backlog</label>
                    </labels>
                <created>Wed, 16 Dec 2020 14:45:40 +0000</created>
                <updated>Tue, 22 Dec 2020 11:30:12 +0000</updated>
                            <resolved>Mon, 21 Dec 2020 13:43:13 +0000</resolved>
                                                                        <due></due>
                            <votes>0</votes>
                                    <watches>2</watches>
                                                                <comments>
                                                            <comment id="198526" author="557058:4f6bed01-40a6-48d5-8471-7ef21f5ea97c" created="Sun, 20 Dec 2020 22:12:39 +0000"  >&lt;p&gt;Tested with mod-inventory-storage instance table and the results are as expected.&lt;/p&gt;

&lt;ol&gt;
	&lt;li&gt;when optimistic locking is logOnConflict&lt;br/&gt;
POST instance without _version, it is a success and db adds _version = 1. Note, the HTTP response has no _version because POST implementation does not read the updated db record&lt;br/&gt;
PUT instance record without _version or with a wrong _version, it is a success but the module log contains a WARN log entry like below
&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;
06:52:52 [] [] [] [] WARN  ?                    Backend notice: severity=&lt;span class=&quot;code-quote&quot;&gt;&apos;WARNING&apos;&lt;/span&gt;, code=&lt;span class=&quot;code-quote&quot;&gt;&apos;23F09&apos;&lt;/span&gt;, message=&lt;span class=&quot;code-quote&quot;&gt;&apos;Cannot update record ffe24a16-065b-4db9-b3e8-bb7f16f9ee9c because it has been changed: Stored _version is 1, _version of request is &amp;lt;NULL&amp;gt;&apos;&lt;/span&gt;, detail=&lt;span class=&quot;code-quote&quot;&gt;&apos;&lt;span class=&quot;code-keyword&quot;&gt;null&lt;/span&gt;&apos;&lt;/span&gt;, hint=&lt;span class=&quot;code-quote&quot;&gt;&apos;&lt;span class=&quot;code-keyword&quot;&gt;null&lt;/span&gt;&apos;&lt;/span&gt;, position=&lt;span class=&quot;code-quote&quot;&gt;&apos;&lt;span class=&quot;code-keyword&quot;&gt;null&lt;/span&gt;&apos;&lt;/span&gt;, internalPosition=&lt;span class=&quot;code-quote&quot;&gt;&apos;&lt;span class=&quot;code-keyword&quot;&gt;null&lt;/span&gt;&apos;&lt;/span&gt;, internalQuery=&lt;span class=&quot;code-quote&quot;&gt;&apos;&lt;span class=&quot;code-keyword&quot;&gt;null&lt;/span&gt;&apos;&lt;/span&gt;, where=&lt;span class=&quot;code-quote&quot;&gt;&apos;PL/pgSQL function instance_set_ol_version() line 8 at RAISE&apos;&lt;/span&gt;, file=&lt;span class=&quot;code-quote&quot;&gt;&apos;pl_exec.c&apos;&lt;/span&gt;, line=&lt;span class=&quot;code-quote&quot;&gt;&apos;3337&apos;&lt;/span&gt;, routine=&lt;span class=&quot;code-quote&quot;&gt;&apos;exec_stmt_raise&apos;&lt;/span&gt;, schema=&lt;span class=&quot;code-quote&quot;&gt;&apos;&lt;span class=&quot;code-keyword&quot;&gt;null&lt;/span&gt;&apos;&lt;/span&gt;, table=&lt;span class=&quot;code-quote&quot;&gt;&apos;&lt;span class=&quot;code-keyword&quot;&gt;null&lt;/span&gt;&apos;&lt;/span&gt;, column=&lt;span class=&quot;code-quote&quot;&gt;&apos;&lt;span class=&quot;code-keyword&quot;&gt;null&lt;/span&gt;&apos;&lt;/span&gt;, dataType=&lt;span class=&quot;code-quote&quot;&gt;&apos;&lt;span class=&quot;code-keyword&quot;&gt;null&lt;/span&gt;&apos;&lt;/span&gt;, constraint=&lt;span class=&quot;code-quote&quot;&gt;&apos;&lt;span class=&quot;code-keyword&quot;&gt;null&lt;/span&gt;&apos;&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;PUT instance record with correct _version is a success and the log is clean&lt;/p&gt;&lt;/li&gt;
	&lt;li&gt;when optimistic locking is failOnConflict&lt;br/&gt;
POST works fine&lt;br/&gt;
PUT without _version for an existing non versioned record, it is a success and db adds _version = 1&lt;br/&gt;
PUT with correct _version, it is a success&lt;br/&gt;
PUT with wrong _version, 409 response code is returned with body like below.
&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;
When request does not pass _version in
{ &lt;span class=&quot;code-quote&quot;&gt;&quot;message&quot;&lt;/span&gt;: &lt;span class=&quot;code-quote&quot;&gt;&quot;Cannot update record ec5eb802-e8b3-4d0d-95a2-72a422cc4143 because it has been changed: Stored _version is 1, _version of request is &amp;lt;NULL&amp;gt;&quot;&lt;/span&gt;, &lt;span class=&quot;code-quote&quot;&gt;&quot;severity&quot;&lt;/span&gt;: &lt;span class=&quot;code-quote&quot;&gt;&quot;ERROR&quot;&lt;/span&gt;, &lt;span class=&quot;code-quote&quot;&gt;&quot;code&quot;&lt;/span&gt;: &lt;span class=&quot;code-quote&quot;&gt;&quot;23F09&quot;&lt;/span&gt;, &lt;span class=&quot;code-quote&quot;&gt;&quot;where&quot;&lt;/span&gt;: &lt;span class=&quot;code-quote&quot;&gt;&quot;PL/pgSQL function instance_set_ol_version() line 8 at RAISE&quot;&lt;/span&gt;, &lt;span class=&quot;code-quote&quot;&gt;&quot;file&quot;&lt;/span&gt;: &lt;span class=&quot;code-quote&quot;&gt;&quot;pl_exec.c&quot;&lt;/span&gt;, &lt;span class=&quot;code-quote&quot;&gt;&quot;line&quot;&lt;/span&gt;: &lt;span class=&quot;code-quote&quot;&gt;&quot;3337&quot;&lt;/span&gt;, &lt;span class=&quot;code-quote&quot;&gt;&quot;routine&quot;&lt;/span&gt;: &lt;span class=&quot;code-quote&quot;&gt;&quot;exec_stmt_raise&quot;&lt;/span&gt; }
When both db and request have _version but they &lt;span class=&quot;code-keyword&quot;&gt;do&lt;/span&gt; not match
{ &lt;span class=&quot;code-quote&quot;&gt;&quot;message&quot;&lt;/span&gt;: &lt;span class=&quot;code-quote&quot;&gt;&quot;Cannot update record 5b1eb450-ff9f-412d-a9e7-887f6eaeb5b4 because it has been changed: Stored _version is 2, _version of request is 1&quot;&lt;/span&gt;, &lt;span class=&quot;code-quote&quot;&gt;&quot;severity&quot;&lt;/span&gt;: &lt;span class=&quot;code-quote&quot;&gt;&quot;ERROR&quot;&lt;/span&gt;, &lt;span class=&quot;code-quote&quot;&gt;&quot;code&quot;&lt;/span&gt;: &lt;span class=&quot;code-quote&quot;&gt;&quot;23F09&quot;&lt;/span&gt;, &lt;span class=&quot;code-quote&quot;&gt;&quot;where&quot;&lt;/span&gt;: &lt;span class=&quot;code-quote&quot;&gt;&quot;PL/pgSQL function instance_set_ol_version() line 8 at RAISE&quot;&lt;/span&gt;, &lt;span class=&quot;code-quote&quot;&gt;&quot;file&quot;&lt;/span&gt;: &lt;span class=&quot;code-quote&quot;&gt;&quot;pl_exec.c&quot;&lt;/span&gt;, &lt;span class=&quot;code-quote&quot;&gt;&quot;line&quot;&lt;/span&gt;: &lt;span class=&quot;code-quote&quot;&gt;&quot;3337&quot;&lt;/span&gt;, &lt;span class=&quot;code-quote&quot;&gt;&quot;routine&quot;&lt;/span&gt;: &lt;span class=&quot;code-quote&quot;&gt;&quot;exec_stmt_raise&quot;&lt;/span&gt; }
When db has no _version but the request body has a _version. This should not happen in real life.
{ &lt;span class=&quot;code-quote&quot;&gt;&quot;message&quot;&lt;/span&gt;: &lt;span class=&quot;code-quote&quot;&gt;&quot;Cannot update record 6506b79b-7702-48b2-9774-a1c538fdd34e because it has been changed: Stored _version is &amp;lt;NULL&amp;gt;, _version of request is 10&quot;&lt;/span&gt;, &lt;span class=&quot;code-quote&quot;&gt;&quot;severity&quot;&lt;/span&gt;: &lt;span class=&quot;code-quote&quot;&gt;&quot;ERROR&quot;&lt;/span&gt;, &lt;span class=&quot;code-quote&quot;&gt;&quot;code&quot;&lt;/span&gt;: &lt;span class=&quot;code-quote&quot;&gt;&quot;23F09&quot;&lt;/span&gt;, &lt;span class=&quot;code-quote&quot;&gt;&quot;where&quot;&lt;/span&gt;: &lt;span class=&quot;code-quote&quot;&gt;&quot;PL/pgSQL function instance_set_ol_version() line 8 at RAISE&quot;&lt;/span&gt;, &lt;span class=&quot;code-quote&quot;&gt;&quot;file&quot;&lt;/span&gt;: &lt;span class=&quot;code-quote&quot;&gt;&quot;pl_exec.c&quot;&lt;/span&gt;, &lt;span class=&quot;code-quote&quot;&gt;&quot;line&quot;&lt;/span&gt;: &lt;span class=&quot;code-quote&quot;&gt;&quot;3337&quot;&lt;/span&gt;, &lt;span class=&quot;code-quote&quot;&gt;&quot;routine&quot;&lt;/span&gt;: &lt;span class=&quot;code-quote&quot;&gt;&quot;exec_stmt_raise&quot;&lt;/span&gt; }
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/li&gt;
	&lt;li&gt;when optimistic locking is off&lt;br/&gt;
Both POST and PUT work fine&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;To enable optimistic locking for a specific table. For example mod-inventory-storage instance table&lt;/p&gt;

&lt;ol&gt;
	&lt;li&gt;in db schema.json, add &quot;withOptimisticLocking&quot; attribute for &quot;instance&quot; table definition
&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;
{
  &lt;span class=&quot;code-quote&quot;&gt;&quot;tableName&quot;&lt;/span&gt;: &lt;span class=&quot;code-quote&quot;&gt;&quot;instance&quot;&lt;/span&gt;,
  &lt;span class=&quot;code-quote&quot;&gt;&quot;withOptimisticLocking&quot;&lt;/span&gt;: &lt;span class=&quot;code-quote&quot;&gt;&quot;logOnConflict&quot;&lt;/span&gt;,
  ...
}
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/li&gt;
	&lt;li&gt;in instance.json, add &quot;_version&quot; field
&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;
{
  &lt;span class=&quot;code-quote&quot;&gt;&quot;$schema&quot;&lt;/span&gt;: &lt;span class=&quot;code-quote&quot;&gt;&quot;http:&lt;span class=&quot;code-comment&quot;&gt;//json-schema.org/draft-04/schema#&quot;&lt;/span&gt;,
&lt;/span&gt;  &lt;span class=&quot;code-quote&quot;&gt;&quot;description&quot;&lt;/span&gt;: &lt;span class=&quot;code-quote&quot;&gt;&quot;An instance record&quot;&lt;/span&gt;,
  &lt;span class=&quot;code-quote&quot;&gt;&quot;type&quot;&lt;/span&gt;: &lt;span class=&quot;code-quote&quot;&gt;&quot;object&quot;&lt;/span&gt;,
  &lt;span class=&quot;code-quote&quot;&gt;&quot;properties&quot;&lt;/span&gt;: {
   &lt;span class=&quot;code-quote&quot;&gt;&quot;_version&quot;&lt;/span&gt;: {
    &lt;span class=&quot;code-quote&quot;&gt;&quot;type&quot;&lt;/span&gt;: &lt;span class=&quot;code-quote&quot;&gt;&quot;integer&quot;&lt;/span&gt;,
    &lt;span class=&quot;code-quote&quot;&gt;&quot;description&quot;&lt;/span&gt;: &lt;span class=&quot;code-quote&quot;&gt;&quot;Record version &lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt; optimistic locking&quot;&lt;/span&gt;
   }
  ...
}
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/li&gt;
	&lt;li&gt;update raml file to define 409 response code. For example in instance-storage.raml add below for /{instanceId} API
&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;
put:
  responses:
    409:
      description: &lt;span class=&quot;code-quote&quot;&gt;&quot;Conflict&quot;&lt;/span&gt;
      body:
        text/plain:
          example: &lt;span class=&quot;code-quote&quot;&gt;&quot;Optimistic locking version has changed&quot;&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ol&gt;
</comment>
                                                            <comment id="198527" author="557058:b8e64633-1f7c-402d-9caf-9959a5ba5d0d" created="Mon, 21 Dec 2020 12:07:44 +0000"  >&lt;p&gt;&lt;a href=&quot;https://folio-org.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3A4f6bed01-40a6-48d5-8471-7ef21f5ea97c&quot; class=&quot;user-hover&quot; rel=&quot;557058:4f6bed01-40a6-48d5-8471-7ef21f5ea97c&quot; data-account-id=&quot;557058:4f6bed01-40a6-48d5-8471-7ef21f5ea97c&quot; accountid=&quot;557058:4f6bed01-40a6-48d5-8471-7ef21f5ea97c&quot; rel=&quot;noreferrer&quot;&gt;Hongwei Ji&lt;/a&gt; Thanks for verifying it! This is great.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10003">
                    <name>Relates</name>
                                            <outwardlinks description="relates to">
                                        <issuelink>
            <issuekey id="57363">RMB-778</issuekey>
        </issuelink>
                            </outwardlinks>
                                                                <inwardlinks description="relates to">
                                        <issuelink>
            <issuekey id="57362">RMB-777</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10000" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummarycf">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10057" key="com.atlassian.jira.plugin.system.customfieldtypes:select">
                        <customfieldname>Development Team</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10144"><![CDATA[Core: Platform]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_10019" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>0|i025s7:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_10020" key="com.pyxis.greenhopper.jira:gh-sprint">
                        <customfieldname>Sprint</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue id="1462">CP: sprint 104</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_10044" key="com.atlassian.jira.plugin.system.customfieldtypes:float">
                        <customfieldname>Story Points</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10024" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>[CHART] Date of First Response</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Mon, 21 Dec 2020 12:07:44 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10025" key="com.atlassian.jira.ext.charting:timeinstatus">
                        <customfieldname>[CHART] Time in Status</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                    </customfields>
    </item>
</channel>
</rss>