[MGNLSYNC-56] SynchronizationRequests can be created with non-unique ids Created: 24/Mar/21  Updated: 20/Jul/22  Resolved: 13/May/22

Status: Closed
Project: Magnolia Synchronization Module
Component/s: None
Affects Version/s: 2.0
Fix Version/s: 2.0.1

Type: Bug Priority: Neutral
Reporter: Brandon Murdoch Assignee: Roman Kovařík
Resolution: Fixed Votes: 0
Labels: None
Σ Remaining Estimate: Not Specified Remaining Estimate: Not Specified
Σ Time Spent: Not Specified Time Spent: Not Specified
Σ Original Estimate: Not Specified Original Estimate: Not Specified

Sub-Tasks:
Key
Summary
Type
Status
Assignee
MGNLSYNC-61 Provide PR with a fix Sub-task Completed Roman Kovařík  
MGNLSYNC-62 Code review Sub-task Completed Adam Siska  
MGNLSYNC-63 Replicate the use case Sub-task Completed Roman Kovařík  
MGNLSYNC-64 Preint QA Sub-task Completed Adam Siska  
MGNLSYNC-65 Add MGNLSYNC project to changelog and... Sub-task Completed Roman Kovařík  
MGNLSYNC-66 Final QA Sub-task Completed Jaromir Sarf  
MGNLSYNC-67 Raise module version in DX-core Sub-task Completed Adam Siska  
Template:
Acceptance criteria:
Empty
Task DoD:
[X]* Doc/release notes changes? Comment present?
[X]* Downstream builds green?
[X]* Solution information and context easily available?
[X]* Tests
[X]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[X]* Steps to reproduce, expected, and actual results filled
[X]* Affected version filled
[ ]* 6.1.6
Date of First Response:
Epic Link: Nucleus Quality Maintenance
Sprint: Nucleus 10
Story Points: 3
Team: Nucleus

 Description   

In my use-case, I create a list of synchronization requests (for my 14 workspaces). These happen sequentially, but evidently too quickly, as the ID for each request is the same. This makes it impossible to get information about a particular request from the synchronization manager. 

Steps to reproduce

  1. For loop over the below method, to create requests: 
    private SynchronizationRequest createSynchronizationRequest(String url, String workspace) {
      SynchronizationRequest req = new SynchronizationRequest();
      req.setUrl(url);
      req.setWorkspace(workspace);
      req.setFromPath("/");
      req.setToPath("/");
      return req;
    }
    
  1.  note that all the requests will have the same id: `req.getIdentifier()`

Expected results

Requests should have unique IDs, so that they can be queried by ID later. 

Actual results

Requests have the same identifier. 

Workaround

I manually appended the workspace to the identifier: 

 

private SynchronizationRequest createSynchronizationRequest(String url, String workspace) {
  SynchronizationRequest req = new SynchronizationRequest();
// THIS LINE  
  req.setIdentifier(generateNewSyncId(workspace));
// ^^^^^^^
  req.setUrl(url);
  req.setWorkspace(workspace);
  req.setFromPath(ROOT_PATH);
  req.setToPath(ROOT_PATH);
  
  return req;
}

The generateNewSyncId() method just creates a string from the date + the workspace. 

Development notes



 Comments   
Comment by Antonín Juran [ 03/May/22 ]

Discovery completed

Unique part of identifier of SynchronizationRequest are milliseconds of current date/time - created in its makeIdentifier() method (https://git.magnolia-cms.com/projects/ENTERPRISE/repos/synchronization/browse/magnolia-synchronization-core/src/main/java/info/magnolia/synchronization/manager/SynchronizationRequest.java#43). Multiple instances of SynchronizationRequest can have the same identifier if they're created too fast in a loop. In order to have each SynchronizationRequest instance unique UUID we could replace or append to formatted "current date" part an UUID created by java.util.UUID.randomUUID().

Comment by Rabie Hayoun [ 06/May/22 ]
  1. Check that we don't break sorting by introducing the random UUID
    • We should be ordering by other properties as date if that the case.
Comment by Jaromir Sarf [ 13/May/22 ]

For RN:

SynchronizationRequest class uses UUID.randomUUID() method to generate identifier instead of date based generating.

Generated at Mon Feb 12 07:39:26 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.