Re: CalciteRemoteDriverTest vs avatica.MetaImpl vs avatica.server.Main thread safety

2019-02-15 Thread Julian Hyde
Simplest thing would be a singleton guarded by some kind of lock. But I haven’t looked at the code. > On Feb 15, 2019, at 12:59 PM, Vladimir Sitnikov > wrote: > > Julian> allocate a new object per request > > Josh> The Meta implementation inside of the Avatica server is a singleton, > > Juli

Re: CalciteRemoteDriverTest vs avatica.MetaImpl vs avatica.server.Main thread safety

2019-02-15 Thread Vladimir Sitnikov
Julian> allocate a new object per request Josh> The Meta implementation inside of the Avatica server is a singleton, Julian, I don't think singletones can be allocated per request. I don't think final fields of singletones can be changed on a per-request basis. What's your suggestion then? I've

Re: CalciteRemoteDriverTest vs avatica.MetaImpl vs avatica.server.Main thread safety

2019-02-15 Thread Julian Hyde
Common strategies for implementing servers using non-thread-safe objects: use one object and ensure only one thread uses it at a time (the actor model), allocate a new object per request, or (if creating an object is expensive) pool objects and re-use them for later requests. > On Feb 15, 2019,

Re: CalciteRemoteDriverTest vs avatica.MetaImpl vs avatica.server.Main thread safety

2019-02-15 Thread Vladimir Sitnikov
Julian> Indeed, JDBC itself is not thread-safe Just in case: CalciteRemoteDriverTest seems to be pretty sane test (it does not use the same java.sql.Connection across multiple threads), yet it fails with race-condition-like reasons. I won't really want to dig into JDBC thread-safety, however that

Re: CalciteRemoteDriverTest vs avatica.MetaImpl vs avatica.server.Main thread safety

2019-02-15 Thread Julian Hyde
+1 what Josh said. Also: non-thread-safe is not necessarily a bad thing. As long as the caller knows the limitation. Code that is written only to work single-threaded is more efficient and has fewer bugs. Indeed, JDBC itself is not thread-safe. It is not safe for two threads to access the sam

Re: CalciteRemoteDriverTest vs avatica.MetaImpl vs avatica.server.Main thread safety

2019-02-14 Thread Josh Elser
The Meta implementation inside of the Avatica server is a singleton, so yes the implementation must be threadsafe as the server will dispatch multiple user request threads to it. The Meta implementation is largely (by virtue of the wire API) stateless. I think the expectation should be that all

CalciteRemoteDriverTest vs avatica.MetaImpl vs avatica.server.Main thread safety

2019-02-14 Thread Vladimir Sitnikov
Hi, CalciteRemoteDriverTest seems to be very unstable at https://builds.apache.org/job/Calcite-Master/ I guess the problem there is the test is using a single CalciteMetaImpl object to handle all the requests. Apparently CalciteMetaImpl is using no synchronization and it uses simple HashMaps (Met