[Branch-2.7] Fix ledger roll over scheduler task#11226
Conversation
eolivelli
left a comment
There was a problem hiding this comment.
overall the change looks good to me.
but I am afraid that we are adding a new flaky test
can you please check my comment ?
| // the ledger rollover scheduled time is between 1000 and 1050 ms, | ||
| // wait 1100 ms, the ledger should be rolled over. | ||
| Awaitility.await() | ||
| .atMost(1100, TimeUnit.MILLISECONDS) |
There was a problem hiding this comment.
I am not sure that on CI we can rely on making the difference in the order of 100ms
it is possible that the machine is very slow and then we will see the test failing
There was a problem hiding this comment.
Yes, I'll increase the time order of magnitude, we could set the maximum rollover time to 10 seconds and wait 11 seconds? Maybe 1 second is more stable?
There was a problem hiding this comment.
In general, I think it's better not to test accurate timings. The test code is cleaner when .atMost is omitted. The default value is 10 seconds and that should be suitable for most cases where the operation is expected to complete in less than 10 seconds.
982fb46 to
71c86d3
Compare
…edLedgerImpl` 2. scheduled the ledger rollover task after update ledger last created time
…eachMaximumRolloverTime`
71c86d3 to
9b02015
Compare
The PR #11116 couldn't be cherry-picked to
branch-2.7, because there are too many conflicts.In PR #8946 the ledger rollover task had been moved from
BrokerServicetoManagedLedgerImpl, and this PR is based on it.Motivation
Currently, the ledger rollover scheduled task will execute before reach the ledger maximum rollover time, this will cause the ledger doesn't roll over in time.
Modifications
Only make the ledger rollover scheduled task after the ledger created successfully.
If the scheduled task was executed when there is no entry in the current ledger, the scheduled task will not be re-executed, and if there is new entry is added the ledger will rollover.
Verifying this change
Add a unit test to verify the ledger could be rolled over in time.
Does this pull request potentially affect one of the following parts:
If
yeswas chosen, please highlight the changes