-
Notifications
You must be signed in to change notification settings - Fork 852
Same Name Services on Different Databases - Foxx Bug #2969
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
Comments
Why nobody answering? |
You mentioned the following sequence of operations to reproduce the problem:
However, what is each request to "/yabco-service/rpc" supposed to do? Store a document in a collection? How is that collection accessed exactly (e.g. by what means and what code)? Does the last line "the data is stored on yabco-dev instead of yabco" mean that for the third request the data is stored in "yabco-dev" whereas it should rather be stored in "yabco"? Or do yo refer to any data being stored in "yabco-dev" (which is probably expected as one of the above requests was sent to "yabco-dev". |
I'll explain a situation that happens when we start the dev server (a single req sent to yabco-service-dev is enough to reproduce the bug), When I login, a session with a token is inserted into the respected database. I have a user, named ali, on both yabco and yabco-dev. I run the A.com app server. a single req is made to yabco-service for some initializations. I try to login into A.com using ali, I check the token stored in the cookie, it is not stored in yabco, it is stored in yabco-dev!!! now I go back and login again, now I'm successfully in the dashboard page. |
I've also added some logging to my services both on yabco and yabco-dev. |
I captured a video to better demonstrate the situation: |
@p30arena That you're seeing the same problem even when you rename the service leads me to believe there's something else going on with your setup. Can you please try the following:
There are numerous reasons I don't think the described behaviour could occur in ArangoDB itself (especially the part where documents end up in the wrong database) and I'm fairly confident the problematic behaviour originates either in the browser (e.g. AJAX against the wrong domain) or in a misconfigured proxy. However if this really is an issue in ArangoDB it's difficult to diagnose it further without a minimal test case we can explore. Based on your description I would assume the problem to persist in the following scenario:
@mpv1989 Can you maybe give the above steps a try? I know development mode affects the routing, so I wouldn't completely rule out there's something wonky going on inside Foxx. |
@pluma I did what you asked for, the issue is not related to the proxy, as I said before I placed logs on both proxies to check if anything goes wrong! Please take note that yabco-service is running in production mode but yabco-service-dev is running in development mode. here's the video for the POC: |
@pluma is it related to the Manifest?? This is the manifest for both the yabco-service and yabco-service-dev:
when I switch from prod to dev and back again, the service reads the manifest. |
I changed the manifests and again did the steps that @pluma asked.
The problem still exists, I'm confused 😕
|
Okay, that's pretty disturbing, especially because neither the db nor the mount paths are the same. The "name" field in the manifest should be irrelevant as it's mostly cosmetical. Thanks for confirming this with a minimal example. Can you clarify how you access the collection? Do you use the |
and I use the router:
|
@p30arena : is the assignment const usersCollection = db._collection('users'); done outside out the routes?
|
@jsteemann that's exactly what we do
then in the route we call the function.
If thats the case, it must be a bug related to Foxx, they are two services on two different databases, with two separate memory allocations, why should my objects interfere? |
@jsteemann That seems unlikely. Foxx service files (including bundled dependencies) are cached per service per db, not globally like other JS files. It's not necessary to create the collection reference per route, in fact none of the Foxx examples do this. @p30arena wait, you're redefining something on the In other words: all instances of the service (in the same context but across different databases) will share the reference This also explains why the mount path is irrelevant. I suggest you don't pollute the global object. The kind of meta-programming you're doing with dynamic requires in a lookup table is already a bit dubious (e.g. your code will likely fail on Windows systems) but if you really want something "global" to all your service files but not the database, consider using |
We should probably add a warning about modifying "global" in the documentation somewhere. Probably in the incompatibility caveat section (which currently lives in the chapter on dependencies but should probably go somewhere else). |
@pluma that's weird, why should the global var be accessible to all of the services?! |
@pluma I fucked everything by using this line: |
The "global" object is global. There's no way around this. FWIW the recommended approach would be to extract your model map into a separate module you can require wherever you need it and then use that. Polluting the global namespace is generally discouraged in any JavaScript environment as far as I'm aware. EDIT: Try search and replace maybe? |
(I have no time for refactoring right now, this is not a good solution, but it works) I placed all global vars in exp;
now in another module, I use this code to define vars:
|
I really think you should be putting these in modules and require them as needed. I also think you shouldn't use eval: https://stackoverflow.com/questions/86513/why-is-using-the-javascript-eval-function-a-bad-idea Using |
ArangoDB 3.2.2 containing this bugfix is available for download - thanks for reporting. Closing. |
Uh oh!
There was an error while loading. Please reload this page.
my environment running ArangoDB
I'm using the latest ArangoDB of the respective release series:
Mode:
Storage-Engine:
On this operating system:
Foxx
These are the steps to reproduce:
...
yabco-service on yabco, is running in production mode.
yabco-service on yabco-dev, is running in development mode.
0- create two services with mount points of /yabco-service on two different databases with different users, say yabco and yabco-dev.
---
To make sure its not from same name
To make sure that the error was not from me, I changed the second service name from yabco-service to yabco-service-dev.
now on yabco I have yabco-service
and on yabco-dev I have yabco-service-dev
UPDATE
Even changing the service name doesn't help!
I have to go and switch the service from prod to dev and again from dev to prod mode, so to make the data get stored in the correct Database!
What a nasty BUG! 👎
@jsteemann @mpv1989 @pluma @fceller @hkernbach
The text was updated successfully, but these errors were encountered: