Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nebulex.RegistryLookupError #207

Closed
Arp-G opened this issue Jun 15, 2023 · 9 comments
Closed

Nebulex.RegistryLookupError #207

Arp-G opened this issue Jun 15, 2023 · 9 comments

Comments

@Arp-G
Copy link

Arp-G commented Jun 15, 2023

Hi, firstly thank you for this very useful library. We have been using Nebulex for some time, and its really good.

We are utilizing Nebulex for caching purposes, but we frequently encounter the following error
(Nebulex.RegistryLookupError) could not lookup Nebulex cache App.API.Cache.UserCache because it was not started or it does not exist

This issue often arises when code changes trigger recompilation while the server is running or when manually recompiling in the iex session. The only solution we have found is to restart the server.

To provide some context, we have an umbrella app that consists of the following apps:

  • web: Live view user-facing app (does not have nebulex)
  • admin: Live view internal admin app (has nebulex)
  • api: GraphQL API app (has nebulex)
  • db: DB schemas, changeset, contexts (has nebulex)
  • pool: Background jobs, cron jobs, Broadway, etc. (has nebulex)

This is only a problem in our development environment and not in production or staging, but because of this our development cycle becomes slower since we frequently need to restart the server to overcome this error.

Any ideas on how to solve this would be very helpful

PS: I also posted this issue along with a few other issues here in elixirforum

@cabol
Copy link
Owner

cabol commented Jun 15, 2023

Hey! This scenario looks tricky, but based on what you say, seems like when code changes trigger recompilation or you recompile within the iex session the cache is stopped for some reason (which is weird), and at the same time there are other processes (perhaps in another app) doing calls using that cache. When Nebulex.RegistryLookupError is raised, is it something temporal (perhaps the cache is restarted at some point)? Or do you continuously get the error (and then you have to restart the server)?

@Arp-G
Copy link
Author

Arp-G commented Jun 15, 2023

The error is continuous.

It happens often like this

  • We made a code change
  • Refreshed the page and got the error
  • Now if we refresh the page again or visit any other path we will keep getting the error

Only after we kill the server and restart the app it is fixed

@cabol
Copy link
Owner

cabol commented Jun 15, 2023

Ok, it is weird, I mean, I'm wondering what can cause the cache to stop, because that is what it looks like, but it is hard to tell. We will need a way to reproduce it so we can debug it and see what is happening, so, if you have like a dummy app we can use to reproduce the issue would be really helpful.

@Arp-G
Copy link
Author

Arp-G commented Jun 15, 2023

Yes, I understand. I think it would be hard to reproduce this in a dummy repo but I can try.

Quick question, when the code recompiles, I believe a new version of the code is loaded. So the existing processes that are running the old code need to be shut down and restarted with the new version of the code (my understanding, I may be incorrect).

So maybe the nebulex cache process is stopping due to this code recompilation?

@cabol
Copy link
Owner

cabol commented Jun 15, 2023

Yes, I understand. I think it would be hard to reproduce this in a dummy repo but I can try.

That would be really helpful, thanks!

A question, are you using Phoenix.CodeReloader for this? If so, can you share an example of how it is configured?

@Arp-G
Copy link
Author

Arp-G commented Jun 16, 2023

These are the configurations we have in the different umbrella apps

In the admin app

# Code reloading can be explicitly enabled under the
  # :code_reloader configuration of your endpoint.
  if code_reloading? do
    socket("/phoenix/live_reload/socket", Phoenix.LiveReloader.Socket)
    plug(Phoenix.LiveReloader)
    plug(Phoenix.CodeReloader)
  end

In the api app

  # Code reloading can be explicitly enabled under the
  # :code_reloader configuration of your endpoint.
  if code_reloading? do
    plug Phoenix.CodeReloader
  end

In the web app

  # Code reloading can be explicitly enabled under the
  # :code_reloader configuration of your endpoint.
  if code_reloading? do
    socket "/phoenix/live_reload/socket", Phoenix.LiveReloader.Socket
    plug Phoenix.LiveReloader
    plug Phoenix.CodeReloader
  end

@cabol
Copy link
Owner

cabol commented Jun 16, 2023

I've run some test scenarios to see if I can reproduce the issue but didn't succeed, they worked fine.

  1. I created a single-app Phoenix app and added a Nebulex cache invoked every time the sample page is rendered. I triggered the code reload and the cache kept working fine. I couldn't reproduce the issue this way.
  2. In the second attempt, I created an umbrella app instead, a dummy Phoenix app using the --umbrella option. That basically creates two apps, one for the domain and another one for the web interface. I added a cache to the domain app, and use it from the web app when the sample page is hit (same as the previous scenario). And again, I triggered the code reload and the cache kept working fine. I couldn't reproduce the issue this way either.

Most likely I'm missing something, hence, I'd definitely need you to provide a dummy app to reproduce the issue. Thanks!

@cabol
Copy link
Owner

cabol commented Dec 7, 2023

Is there any feedback about this? If not, I think we can close the issue

@Arp-G
Copy link
Author

Arp-G commented Dec 8, 2023

We reduced the number of umbrella apps we had, we don't see this error very often right now. I am closing this issue for now.

@Arp-G Arp-G closed this as completed Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants