Translation of AST::Select is not thread-safe.
Parallelizing of queries to different tables sometimes end up in PostgreSQL complaining on wrong query syntax. In particular, a SELECT would refer to table it doesn't fetch from.
Took me some time to track down the cause. It is described in rakudo/rakudo#2882. Red is applying an anonymous role to a column object in Red::Driver::CommonSQL where the failure happens.
It seems like I have a solution and would try to provide a PR ASAP.
There're more thread-related issues are lurking in the code. I'm trying to find out why out of sudden > and gt operators stop working. Most likely some other are broken too.
<Strike>Running tests with prove6 also reveal few more issues. Pardon me, forgot about prove6 -l switch.
I don't think I'd have time to get this investigated. Fell free to close this issue if you think it's polluting the tracker.