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

Preserve an active domain on I/O in native bindings #354

Merged
merged 2 commits into from
May 20, 2013

Conversation

andreypopp
Copy link
Contributor

Native binding didn't preserve an active domain on I/O because of native connection didn't handle it. I've provided a fix with two test cases.

@brianc
Copy link
Owner

brianc commented May 20, 2013

This is perfectamundo. 👍

You probably know using the connection pool + domains is a whole other nightmare. I think the node core team plans on addressing that somewhat in the future, but I still might work on a patch within node-postgres until core addresses the issue.

brianc added a commit that referenced this pull request May 20, 2013
Preserve an active domain on I/O in native bindings
@brianc brianc merged commit 1995601 into brianc:master May 20, 2013
@andreypopp andreypopp deleted the native-fix-domain branch May 20, 2013 22:25
@andreypopp
Copy link
Contributor Author

You probably know using the connection pool + domains is a whole other nightmare

That's interesting, can you share what exact problems did you have there?

@brianc
Copy link
Owner

brianc commented May 20, 2013

In the pure javascript version the Client object, each query, the connection (used by the client internally) and the stream are all event emitters. When you call pg.connect if there is no client in the pool (like on the first request) it will create the client/connection/stream & bind them to the current domain. Next request to the pool if the client has been returned it will come back out of the pool on the same domain as it was created, regardless of the requesting domain. The solution is rather simple...switch all the event emitters to the new domain when it's checked out and remove it from a domain when its returned. I just haven't done it yet. I use https://github.com/brianc/node-okay to handle a lot of callback stuff so it isn't a huge deal in my apps, but definitely needs to and will be fixed pretty soon.

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

Successfully merging this pull request may close these issues.

2 participants