You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I just talked to some folks who are using Rethink with a Python client. At some point they added some multiprocessing, and started getting weird issues. After a while, they had a hunch that connections may not be thread safe, so they started opening a connection per thread. That fixed things for them.
So the obvious question here is whether connections should be thread safe. If not, we need to add better documentation (but I think we should answer this question first). I'd like to see what the state of the art on this is for other NoSQL systems.
@coffeemug i ran into this a while ago in my php code i simple create a shared memory segement for each connection so if i have a few forks running and they are aware of other conenctions they will try it but will just creata new one if they have to.
In node.js, being an evented server, wouldn't a connection be unsafe the same as in a multi-threaded environment? the way node.js programming works, it would be quite hard to keep track of queuing work for a connection so that it is only used linearly. Practically meaning that would mean opening a connection per query, rather than engineering non-blocking code to serialize queries, wouldn't it?
It is very unproductive to serialize access to a connection in the node.js programing paradigm...
Is it confirmed that rethinkdb is not thread safe right now? that would mean it's not node.js safe unless each query uses its own connection wouldn't it?
The connections with the node.js driver are "event" safe.
You can fire query1 then query2 without waiting query1 to return.
You won't receive the results for query2 before the results for query1 though.
So while it works, you probably don't want to use a single connection but one connection per query (opening one connection per query, or re-using connections with a pool).
Why actually would I want numerous connections with node.js? each connection has overheads in waiting for it to open, and in memory allocations on both ends, so why would it not be recommended to reuse one?
Thanks!
@matanster from my guess i am thinking what this means is that if you have a really big long query on the same same connection started before a super fast short query the long blocking querying wil make the short one be delayed so if you had one connection per query/request you will get less blacking
Makes sense @wojons, and happy to hear @neumino!
Me and rethinkdb are back on now, but I still feel like a very early adopter :) please avoid adding too many features but rather focus on making everything common just work well and robust... too many features make the basics slower and inflate documentation and user group forums. Excuse the plug..
@matanster -- thanks for chiming in with more general feedback, it helps prioritize things a lot. Would you mind taking a few minutes to write down which parts of RethinkDB still feel like rough edges? It would help immensely. Feel free to email your feedback to me ([email protected]) if it's too rough for github issues.
Activity
neumino commentedon Mar 11, 2014
We could provide a connection pool that is thread safe maybe?
coffeemug commentedon Mar 11, 2014
Related to #281.
mlucy commentedon Mar 11, 2014
An intermediate option would be detecting when one connection is accessed from multiple threads and erroring.
wojons commentedon Mar 12, 2014
@coffeemug i ran into this a while ago in my php code i simple create a shared memory segement for each connection so if i have a few forks running and they are aware of other conenctions they will try it but will just creata new one if they have to.
matanox commentedon Mar 16, 2014
In node.js, being an evented server, wouldn't a connection be unsafe the same as in a multi-threaded environment? the way node.js programming works, it would be quite hard to keep track of queuing work for a connection so that it is only used linearly. Practically meaning that would mean opening a connection per query, rather than engineering non-blocking code to serialize queries, wouldn't it?
It is very unproductive to serialize access to a connection in the node.js programing paradigm...
Is it confirmed that rethinkdb is not thread safe right now? that would mean it's not node.js safe unless each query uses its own connection wouldn't it?
neumino commentedon Mar 16, 2014
The connections with the node.js driver are "event" safe.
You can fire
query1thenquery2without waitingquery1to return.You won't receive the results for
query2before the results forquery1though.So while it works, you probably don't want to use a single connection but one connection per query (opening one connection per query, or re-using connections with a pool).
matanox commentedon Mar 17, 2014
Why actually would I want numerous connections with node.js? each connection has overheads in waiting for it to open, and in memory allocations on both ends, so why would it not be recommended to reuse one?
Thanks!
wojons commentedon Mar 17, 2014
@matanster from my guess i am thinking what this means is that if you have a really big long query on the same same connection started before a super fast short query the long blocking querying wil make the short one be delayed so if you had one connection per query/request you will get less blacking
matanox commentedon Mar 17, 2014
Makes sense @wojons, and happy to hear @neumino!
Me and rethinkdb are back on now, but I still feel like a very early adopter :) please avoid adding too many features but rather focus on making everything common just work well and robust... too many features make the basics slower and inflate documentation and user group forums. Excuse the plug..
coffeemug commentedon Mar 17, 2014
@matanster -- thanks for chiming in with more general feedback, it helps prioritize things a lot. Would you mind taking a few minutes to write down which parts of RethinkDB still feel like rough edges? It would help immensely. Feel free to email your feedback to me ([email protected]) if it's too rough for github issues.
coffeemug commentedon May 21, 2014
Closing as dup of #2427 (that one has more information).
coffeemug commentedon May 21, 2014
Err, I guess #2427 is python specific, while this issue encompasses all drivers. Reopening.