Dikran Seropian created OAK-12326:
-------------------------------------

             Summary: Flacky test TokenCleanupTest#testBatchSizeLimitsCleanup
                 Key: OAK-12326
                 URL: https://issues.apache.org/jira/browse/OAK-12326
             Project: Jackrabbit Oak
          Issue Type: Bug
          Components: security
            Reporter: Dikran Seropian


In 
[https://github.com/apache/jackrabbit-oak/blob/03499ab99de715f054b3ed0e9787c928d9fb2858/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authentication/token/TokenCleanupTest.java#L100]

 
{code:java}
org.apache.jackrabbit.oak.security.authentication.token.TokenCleanupTest#testBatchSizeLimitsCleanup{code}
 

 
TokenProviderImpl.cleanupExpired runs opportunistically on every createToken 
call whenever shouldRunCleanup(token) is true (~1/8 random chance).
 
In the test, the cleanup threshold (5) equaled the number of expired tokens 
created, so the 5th expired-token creation could randomly trigger an extra 
cleanup batch. When that happened, two batches ran and all 5 expired tokens 
were removed instead of only batchSize (3), producing the intermittent failure.
 
The fix would be to raise the cleanup threshold to expiredCount + 1 so cleanup 
can never fire during the expired-token creation phase, guaranteeing exactly 
one cleanup batch during the extras loop. This makes the batch-size assertion 
deterministic.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to