This is logged as a Bug internally as other customers have faced the same issue. GRANITE-28723 is the internal bug ID.
You can use the following workarounds till the issue is officially fixed:
- Run workflow purge more often to reduce the number of nodes.
- Increase the Query limit to let the query complete. Default query limit is 100000. So, a query that traverses more than 100000 nodes will be stopped by AEM