Resolved on StackOverflow:
You are most likely exceeding the default limit related to queries. First, see the definition for error code 22:
For scans with server 4.7 or later, no threads available (
Based on your other question, you’re doing scans rather than a query with a secondary index. You’ll need to increase that limit, as suggested in the ‘Additional Information’. However, you have a pretty weak system in terms of CPU, so you should adjust that value and benchmark, comparing performance before and after with the same workload. In a real production system you’d have multiple nodes, probably want more than two CPU cores, and similarly tune the scan threads as needed.