You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@kudu.apache.org by John Mora <jh...@gmail.com> on 2019/08/24 05:55:15 UTC
KuduSession - is not thread-safe
Hi.
The javadoc documentation of the class KuduSession[1] claims that it is not
thread-safe. So, I was wondering If there is a pooling mechanism or similar
for multi-threaded applications.
I would like to execute multiple operations such as: session.apply(upsert),
session.apply(update) and session.apply(delete) in a multiple threads using
a shared variable session.
Is that possible? How should I be handling KuduSession and flushing in a
multi thread environment.
Thanks in advance for your help.
[1] https://kudu.apache.org/apidocs/org/apache/kudu/client/KuduSession.html
Cheers,
John Mora.
Re: KuduSession - is not thread-safe
Posted by Alexey Serbin <as...@cloudera.com>.
Hi John,
If my understanding is correct, KuduSession is designed to be used by a
single thread, not multiple. For details, see
https://kudu.apache.org/apidocs/org/apache/kudu/client/AsyncKuduSession.html
As Attila mentioned, it's possible to use multiple sessions spawned by the
same KuduClient, and that's the recommended usage pattern for
KuduClient/KuduSession. Would using multiple sessions on the same
KuduClient fit your case? Otherwise, what is the rationale behind using a
single session by multiple threads?
Thanks,
Alexey
On Sat, Aug 24, 2019 at 1:27 AM Attila Bukor <ab...@apache.org> wrote:
> Hi John,
>
> I’m not sure if there’s a existing pooling solution that would work, but I
> would suggest handle locking manually in your application by putting the
> session.apply(op) in a synchronized (session) block. I believe you could
> also use multiple sessions on the same client.
>
> Attila
>
> Sent from my iPhone
>
> On Aug 24, 2019, at 7:55 AM, John Mora <jh...@gmail.com> wrote:
>
> Hi.
>
> The javadoc documentation of the class KuduSession[1] claims that it is
> not thread-safe. So, I was wondering If there is a pooling mechanism or
> similar for multi-threaded applications.
>
> I would like to execute multiple operations such as:
> session.apply(upsert), session.apply(update) and session.apply(delete) in a
> multiple threads using a shared variable session.
>
> Is that possible? How should I be handling KuduSession and flushing in a
> multi thread environment.
>
> Thanks in advance for your help.
>
> [1]
> https://kudu.apache.org/apidocs/org/apache/kudu/client/KuduSession.html
>
> Cheers,
> John Mora.
>
>
Re: KuduSession - is not thread-safe
Posted by Attila Bukor <ab...@apache.org>.
Hi John,
I’m not sure if there’s a existing pooling solution that would work, but I would suggest handle locking manually in your application by putting the session.apply(op) in a synchronized (session) block. I believe you could also use multiple sessions on the same client.
Attila
Sent from my iPhone
> On Aug 24, 2019, at 7:55 AM, John Mora <jh...@gmail.com> wrote:
>
> Hi.
>
> The javadoc documentation of the class KuduSession[1] claims that it is not thread-safe. So, I was wondering If there is a pooling mechanism or similar for multi-threaded applications.
>
> I would like to execute multiple operations such as: session.apply(upsert), session.apply(update) and session.apply(delete) in a multiple threads using a shared variable session.
>
> Is that possible? How should I be handling KuduSession and flushing in a multi thread environment.
>
> Thanks in advance for your help.
>
> [1] https://kudu.apache.org/apidocs/org/apache/kudu/client/KuduSession.html
>
> Cheers,
> John Mora.