Replies: 2 comments 1 reply
-
That's kind of expected behavior as the connection interface is not just postgres specific and other backends need the mutable reference there. I think this kind of issue can generally be soved by returning a As for the documentation: PR's improving the documentation are always welcome. |
Beta Was this translation helpful? Give feedback.
-
I have experiment with usage like this where I impl |
Beta Was this translation helpful? Give feedback.
-
Hi!
I've found the pipelining support to work well in simple scenarios, where single queries can be run in parallel, e.g. the result of the query is directly returned to the caller, and the function returns a boxed future, or
impl Future
. In these cases, multiple queries can be run concurrently withtry_join!
.The issue/limitation I have encountered, is that any use of
async
seems to capture the connection, so that it's impossible to create any further concurrent calls:cannot borrow `*conn` as mutable more than once at a time
A very simple example, just based on the signatures:
This will compile as is, because
b_fut
is evaluated last, and so the connection is only captured once. If the order of evaluation ofa_fut
andb_buf
is reversed, compilation fails.It's all fine if there is only one async block. But if I want to use two async blocks — say, there are dependent chains of postgres queries
a->b
andc->d
which I'd like to run concurrently — this is impossible.Has anybody got any workarounds for this? (other than just drop to normal pooling).
And if this is a known and expected ongoing limitation, I can send a PR to update the documentation around pipelining to mention this.
Beta Was this translation helpful? Give feedback.
All reactions