The method WorkManager#listWorkIds is still used in legacy code.
The code needs to be adapted.
These cases are pretty much similar (except for the unit test
- works with the same id or same prefix are scheduled for a document (multiple renditions for a blob or rendition for multiple blobs)
- there is an extra final action to run once all the works are done, like fires an event
Today each Work tries to detect if it is the last one using the listWorkIds and if it is the case execute the final action.
This logic does not scale and can fail in case of race condition:
- it is possible that no final action is run when the 2 last works terminate at the same time (each Work sees the other work as running).
- It is also possible to have duplicate events because the list of work is not atomically done.