ExUnit async: true {:error, :table_not_found} with Ash.DataLayer.Ets

I've recently done a refactor on a test suite to allow all cases to run asynchronously. Unfortunately at some point I've started getting intermittent :table_not_found errors thrown on the actions of an Ets backed resource. It's almost guaranteed to happen when the whole suite (200+ tests) runs asynchronously. Is this expected? Meaning Ash.DataLayer.Ets isn't ready/meant to be used with asynchronous tests or am I missing some proper setup? For reference, these Ets backed resources serve as an in-memory cache to avoid hitting the DB constantly. The main use-case is to cache actor/account permissions to be used by policies.
11 Replies
ZachDaniel
ZachDaniel4mo ago
Not expected, no. We use ETS for all of our Ash testing and I've not seen that before Pretty strange I can't think of why it would happen at this point. Is there anything special you can think of about your setup?
quartz
quartzOP4mo ago
here's an overview of how it is being used. the error is happening in the line with Logger.warning("error fetching cache:")
ZachDaniel
ZachDaniel4mo ago
What's the stack trace of the error?
quartz
quartzOP4mo ago
ZachDaniel
ZachDaniel4mo ago
Interesting. Do you have the disable async config set in test? https://hexdocs.pm/ash/testing.html
quartz
quartzOP4mo ago
yes, I've followed both guidelines for Ash and for Ecto.Adapters.SQL.Sandbox with Postgres
ZachDaniel
ZachDaniel4mo ago
Very very strange 🤔 All access to that stuff ought to be creating the tables before-hand etc.
quartz
quartzOP4mo ago
indeed, from a quick look at the source code that was also my (limited) conclusion this is not a showstopper as it's only happening in the test suite and I can easily ignore it although I reckon it would be hard to try and create a minimum reproducible example for this
ZachDaniel
ZachDaniel4mo ago
Are the stack traces the same in all cases? You might try cloning down ash and putting some debug code in the ets logic
quartz
quartzOP4mo ago
yes it's the same stacktrace all the time I'll let you know if I find some free time to do that 👍

Did you find this page helpful?