Pow: Pow.Store.Backend.EtsCache not being started automatically?

Created on 14 Feb 2019  路  8Comments  路  Source: danschultzer/pow

I have Pow working great in development using the Pow.Store.Backend.MnesiaCache but I'm unable to do it with Pow.Store.Backend.EtsCache:

 stdlib nofile :ets.lookup/2
 lib/pow/store/backend/ets_cache.ex:109 Pow.Store.Backend.EtsCache.table_get/2
 lib/pow/plug/session.ex:62 Pow.Plug.Session.fetch/2
 lib/pow/plug/session.ex:39 Pow.Plug.Session.do_fetch/2
 lib/myapp_web/endpoint.ex:1 MyAppWeb.Endpoint.plug_builder_call/2

The README says this is the default and is started automatically so I don't know why it's not working. Do I have to specify anything else or start it from the supervisor?

Also, why is Pow.Store.Backend.EtsCache discouraged from using it in production? If the only reason to change to MnesiaCache is being able to run in multiple nodes then there's no problem in my case as my app lives in a single node in Heroku.

All 8 comments

It should start automatically, but you may have some application setting that prevents dependency applications from starting. E.g. having :applications instead of :extra_applications set will disable all applications not defined to start.

How do you build the app for production? You may need to add :pow to an application list somewhere.

Using MnesiaCache will persist the sessions between restarts too, but you would need write access.

Thanks, that was it, I still had :applications, changing to :extra_applications fixed the issue.

Thanks also for the explanation about MnesiaCache, definitely persisting sessions between restarts is a nice to-have. I'll check if this can be set up in Heroku somehow. If not, I guess that PowPersistentSession should be enough to remember the logged in user.

Unfortunately that information is wiped too, on server restarts. The PowPersistentSession data is stored in the same cache backend.

There's been other issues posted for how to handle cache backend on Heroku, e.g. using Redis (https://github.com/danschultzer/pow/issues/75#issuecomment-458741517) or Postgres (https://github.com/danschultzer/pow/issues/78).

So I think definitely an alternative to Mnesia is needed for read-only systems. What alternative do you think is most natural for Heroku users? Redis or using the DB with Ecto?

Both sound good to me, Redis and Ecto DB, but Redis sounds like a more suited solution as we're talking about caching.

Thanks! I followed that guide to use Redis and it works great, both locally and in Heroku.

Are there plans to integrate this into Pow?

It won't be integrated into Pow, as I try to keep Pow at near zero dependencies. Without native support for Redis in erlang/elixir this will stay as a guide.

Thanks, makes sense. Maybe this could be releases as a separate library though.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JonRCahill picture JonRCahill  路  3Comments

dweremeichik picture dweremeichik  路  7Comments

blatyo picture blatyo  路  4Comments

joepstender picture joepstender  路  6Comments

mreishus picture mreishus  路  5Comments