Openbravo Issue Tracking System - Retail Modules
View Issue Details
0048847Retail ModulesWeb POSpublic2022-03-21 10:402022-06-22 16:57
aferraz 
AugustoMauch 
normalmajorhave not tried
closedfixed 
5
 
RR22Q3 
No
0048847: JIRA 2948: SynchronizationBuffer loads messages in a random order
When adding more than one message into Messages state model inside the same state action, sometimes the import entry for the second added message is created before the import entry of the first added message.

The problem seems to be that the "time" property of the messages is being considered to sort them, and the time of the OBPOS_Order message is the same one as the time of the messages generated on the backend (see attached screenshot), and as a consequence their order will not be deterministic.
Add following postHook to completeTicket action:
OB.App.StateAPI.Global.completeTicket.addPostHook(globalState => ({
  ...globalState,
  Messages: [
    ...globalState.Messages,
    OB.App.State.Messages.Utils.createNewMessage(
      'MyModel',
      'MyModelEndpoint',
      {}
    )
  ]
}));

Add log into findAll function in MessageModelController.js and check sometimes OBPOS_Order message is retrieved first (the one added inside the state action) and other times MyModel message is retrieved first (the one added inside the post hook).
The same happens in ImportEntryBuilder.createImportEntry.
No tags attached.
related to defect 0048865 closed Retail POS2 Proof of Payment are not always created through Split Payment functionality 
png MessageOrder.png (182,485) 2022-06-04 11:03
https://issues.openbravo.com/file_download.php?file_id=17118&type=bug
png
Issue History
2022-03-21 10:40aferrazNew Issue
2022-03-21 10:40aferrazAssigned To => Triage Platform Base
2022-03-21 10:40aferrazTriggers an Emergency Pack => No
2022-03-21 10:48aferrazDescription Updatedbug_revision_view_page.php?rev_id=23787#r23787
2022-03-21 10:49aferrazSummarySynchronizationBuffer synchronizes messages in a random order => SynchronizationBuffer loads messages in a random order
2022-03-21 10:54aferrazSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=23789#r23789
2022-03-23 08:05andre_montenegroRelationship addedrelated to 0048865
2022-05-26 13:23guilleaerSummarySynchronizationBuffer loads messages in a random order => JIRA 2948: SynchronizationBuffer loads messages in a random order
2022-05-26 13:23guilleaerAssigned ToTriage Platform Base => jarmendariz
2022-05-26 13:23guilleaerStatusnew => acknowledged
2022-06-04 11:03AugustoMauchFile Added: MessageOrder.png
2022-06-04 11:05AugustoMauchDescription Updatedbug_revision_view_page.php?rev_id=24230#r24230
2022-06-04 12:19hgbotNote Added: 0138036
2022-06-04 12:21AugustoMauchAssigned Tojarmendariz => AugustoMauch
2022-06-04 12:21AugustoMauchStatusacknowledged => scheduled
2022-06-04 20:47hgbotNote Added: 0138039
2022-06-10 11:13hgbotNote Added: 0138247
2022-06-10 11:14hgbotResolutionopen => fixed
2022-06-10 11:14hgbotStatusscheduled => closed
2022-06-10 11:14hgbotFixed in Version => RR22Q3
2022-06-10 11:14hgbotNote Added: 0138248
2022-06-13 10:55hgbotNote Added: 0138297
2022-06-13 17:01hgbotNote Added: 0138317
2022-06-22 16:57hgbotNote Added: 0138639

Notes
(0138036)
hgbot   
2022-06-04 12:19   
Merge Request created: https://gitlab.com/openbravo/product/pmods/org.openbravo.mobile.core/-/merge_requests/376 [^]
(0138039)
hgbot   
2022-06-04 20:47   
Merge Request created: https://gitlab.com/openbravo/product/pmods/org.openbravo.mobile.core/-/merge_requests/377 [^]
(0138247)
hgbot   
2022-06-10 11:13   
Merge request merged: https://gitlab.com/openbravo/product/pmods/org.openbravo.mobile.core/-/merge_requests/376 [^]
(0138248)
hgbot   
2022-06-10 11:14   
Directly closing issue as related merge request is already approved.

Repository: https://gitlab.com/openbravo/product/pmods/org.openbravo.mobile.core [^]
Changeset: 1b9d5335c16d4711f4c3305639a9288b2864c233
Author: Augusto Mauch <augusto.mauch@openbravo.com>
Date: 10-06-2022 11:13:18
URL: https://gitlab.com/openbravo/product/pmods/org.openbravo.mobile.core/-/commit/1b9d5335c16d4711f4c3305639a9288b2864c233 [^]

Fixes ISSUE-48847: Guarantees proper message processing order

The problem was that if some messages for the same backend are created within the same millisecond, they will have the same
value in their time property. If two messages have the same time, then when the MessageModelController retrieves them from
the database [1], there will be no guarantee that they are returned in the same order they were added to the messages queue.

To fix it, now the MessageModelController will add a sequence number (its position in the incoming message list) to each message
before storing it in the database. It then uses both the time property and the new sequence number to read the ordered message
list from the database.

Also when setting the time of the message, new Date().getTime() has been replaced with Date.now() because it has better performance.

[1] https://gitlab.com/openbravo/product/pmods/org.openbravo.mobile.core/-/blob/6e7893c6474f5069a30ddc539182d2b8c870c520/web/org.openbravo.mobile.core/app/model/synchronization-buffer/MessageModelController.js\#L46 [^]

---
M web/org.openbravo.mobile.core/app/model/business-object/messages/MessagesUtils.js
M web/org.openbravo.mobile.core/app/model/synchronization-buffer/MessageModelController.js
---
(0138297)
hgbot   
2022-06-13 10:55   
Repository: https://gitlab.com/openbravo/product/pmods/org.openbravo.retail.posterminal [^]
Changeset: 75f57703155bc981939b14c19568adfda78e4bba
Author: Javier Armendáriz <javier.armendariz@openbravo.com>
Date: 13-06-2022 10:55:22
URL: https://gitlab.com/openbravo/product/pmods/org.openbravo.retail.posterminal/-/commit/75f57703155bc981939b14c19568adfda78e4bba [^]

Related to ISSUE-48847: Fixes tests that mocks Date object during Message creation

---
M web-test/model/business-object/cashup/Cashup-completeCashupAndCreateNew.test.js
M web-test/model/business-object/cashup/Cashup-initCashup-StateAction-fromScratch.test.js
---
(0138317)
hgbot   
2022-06-13 17:01   
Repository: https://gitlab.com/openbravo/product/pmods/org.openbravo.mobile.core [^]
Changeset: 7cab8bc36de7d196efb745334ddd258b58791598
Author: Augusto Mauch <augusto.mauch@openbravo.com>
Date: 13-06-2022 17:01:19
URL: https://gitlab.com/openbravo/product/pmods/org.openbravo.mobile.core/-/commit/7cab8bc36de7d196efb745334ddd258b58791598 [^]

Related to ISSUE-48847: MessageModelController.put may receive an array or an object

---
M web/org.openbravo.mobile.core/app/model/synchronization-buffer/MessageModelController.js
---
(0138639)
hgbot   
2022-06-22 16:57   
Merge request closed: https://gitlab.com/openbravo/product/pmods/org.openbravo.mobile.core/-/merge_requests/377 [^]