Skip to content
This repository has been archived by the owner on Oct 27, 2020. It is now read-only.

MNT-18308 force async acl creation #987

Merged
merged 8 commits into from
May 14, 2020

Conversation

evasques
Copy link
Contributor

Replaces PR #984

Implements solution provided by @killerboot :

  • When time is exceeded (set on fixedAclMaxTransactionTime), it shall always turn the call async and delegate ACL creation to the job
  • Fix the current async behavior to also delegate the current's branch children to the job instead of processing them because they have no children

Aditionally also contains:

  • Fix to the FixedACLUpdater job: it was picking up nodes in batches and kept resetting a maxNodeId with the last node of the list so on next iteration it would not pick those up again. Problem is the list is sorted desc, so smallest ID comes last - so the next iteration was picking up everything again except the lowest nodeID from the previous. This caused no error on the job, but threw null pointers as it tried to re-process nodes.
  • Unit test to assert that when time is exceeded in a sync call, the call with turn async, there will be nodes with aspect ASPECT_PENDING_FIX_ACL to be processed by job and job will then process them correctly.

@@ -321,7 +321,9 @@ public boolean handle(Pair<Long, NodeRef> nodePair)
if (nodes.size() < maxItemBatchSize)
{
nodes.add(nodePair.getSecond());
maxNodeId = nodePair.getFirst();
if(nodePair.getFirst() > maxNodeId) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check the formatting settings of your IDE. The braces should be on new lines and a whitespace between "if" and the condition clause.

AlfrescoTransactionSupport.bindResource(FixedAclUpdater.FIXED_ACL_ASYNC_REQUIRED_KEY, true);
// stop propagating on children nodes
return false;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove unnecessary empty lines.

* If async call required adds ASPECT_PENDING_FIX_ACL aspect to nodes when transactionTime reaches max admitted time
* MNT-18308: No longer checks if call is async in order to evaluate time passed to decide if nodes should be processed by job.
* This is now the default behavior for both sync and async calls: when fixedAclMaxTransactionTime is exceeded, call turns
* async and all remaining nodes should be processed by job FixedACLUpdater
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add a description of the method signature in this JavaDoc (parameters and return value description)?

@@ -68,7 +68,8 @@
private FileFolderService fileFolderService;
private Repository repository;
private FixedAclUpdater fixedAclUpdater;
private NodeRef folderNodeRef;
private NodeRef mnt15368folder;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove references to JIRA tickets from variables. Use meaningful names instead.

@@ -225,6 +231,66 @@ public Void execute() throws Throwable
}
}, false, true);
}

@Test
public void testMNT18308()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove references to JIRA tickets from methods. Use meaningful names instead.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to unite this test with testMNT15368 to avoid code duplication?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

testMNT15368 is setting inherit permissions forcing async: permissionService.setInheritParentPermissions(mnt15368folder, false, true);

In order to test MNT-18308 we need to set them sync:
permissionService.setInheritParentPermissions(mnt18308folder, false, false);

In fact, with these changes now, the behavior is exactly the same, so the async/sync flag does not make a difference as async calls behave the same as sync calls until time is exceeded and now sync calls behave the same as async calls when time was exceeded.

testMNT15368 was kept to assert previous behavior is the same on async calls
testMNT18308 was added to assure that a sync call turns async after transaction time was exceeded.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was just trying to highlight that the tests are only different in the first part. The majority of the test is a copy-paste which is discouraged.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, but i cannot reproduce both issues by reapplying the permissions to the previous tree the other test ran on. I'm not sure how I could unite them. Best I can do I think create methods that both call. Do you agree or did you have a better solution in mind?

@evasques evasques requested a review from killerboot May 11, 2020 14:48
if (log.isWarnEnabled() && (AlfrescoTransactionSupport.getResource(FixedAclUpdater.FIXED_ACL_ASYNC_REQUIRED_KEY) == null
|| (Boolean) AlfrescoTransactionSupport.getResource(FixedAclUpdater.FIXED_ACL_ASYNC_REQUIRED_KEY) == false))
{
log.warn("Time was exceeded in transaction " + AlfrescoTransactionSupport.getTransactionId()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to propose to change the message to be a bit more precise:
"The ACL processing time in transaction X exceeded the configured limit of Y ms. The rest of the ACL processing will be done asynchronously."
I guess it is ok to omit some of the information, as the elapsed time (transactionTime) will be very close to the limit and the exact date when this happened will be in the log statement anyways.

Copy link
Contributor

@killerboot killerboot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good. Please see my comment about the log message and the test. Other than that it is ok to merge.

@evasques evasques merged commit c1c0650 into master May 14, 2020
@pr-triage pr-triage bot added the PR: merged label May 14, 2020
@evasques evasques deleted the fix/MNT-18308_force_async_ACL_creation branch May 21, 2020 12:27
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants