calcite connection can't execute sql in another thread - apache-calcite

we open a calcite connection in one thread, and execute sqls in other threads against the connection, and failed with this error:
com.google.common.util.concurrent.ExecutionError: java.lang.NoSuchMethodError:
org.codehaus.commons.compiler.CompilerFactoryFactory.getDefaultCompilerFactory(Ljava/lang/ClassLoader;)Lorg/codehaus/commons/compiler/ICompilerFactory;
the same code works with one thread, do we miss anything regarding to multi-threading with calcite?

Related

Monitor connections instances in a C++ program

In my project I'm using libmodbus
I have a thread that uses a modbus_t connection to check status of multiple RTU slaves.
I want to create another thread that checks for the status of the modbus connection.
If the connection fails the first thread should be stopped.
Any idea or approach can help.
Thanks

Running boost::asio asynchronous server alongside command loop

I'm trying to create a C++ daemon that is capable of asynchronously sending/receiving requests/responses as packets over the network. It should communicate with clients (outwards-facing message API) and other daemons (inter-server messages)
I'm currently looking at boost::asio, specifically http://www.boost.org/doc/libs/1_65_1/doc/html/boost_asio/tutorial/tutdaytime6/src.html as a starting point that seems to be running a server capable of handling async. send and receive.
My question is, could this server be run alongside (in the background) a command loop, such as a process responding to user input (e.g. shell)? The daytime server program provided seems to block on the line io_service.run();
Would this require a forked or separate threaded server?
You simply create a thread member variable, and let the io_service run on the thread. You can process all the process-input in your main-thread, and give your server-class-variable some work to do.
std::thread ioThread;
ioThread = std::thread([this]() { io_service.run(); });
Do not forget to join the thread later and stop the io_service.
io_service.stop();
if (ioThread.joinable())
ioThread.join();

Which mechanism keeps an Oracle session alive on the server?

I have a C++ application that connects to an Oracle database via the Qt QSqlDatabase interface. The main application establishes and uses the connection to the database along with starting a child process for unrelated other porpuses. To make this clear: the child process does not use any database relevant stuff.
The problem is now: If the main process gets terminated in an unusual way (it crashes or it gets killed by the user via the Task Manager), I can see that the database session on the Oracle server gets kept alive and does not timeout whatsoever. Absolutely reproducibly, however, the session gets cancelled immediatelly after I kill the child process manually.
As those dangling, orphaned sessions lead to some problems (the simplest beeing that the max session count on the server gets reached), I would really like all sessions to be closed as soon as possible.
My question now is: what is the mechanism that keeps a session alive on the server just because an irrelevant child process is still alive? How can I control this behavior, i.e. tell the oracle client to disconnect any sessions if the main application process dies?
Thanks in advance!
UPDATE
https://bugreports.qt.io/browse/QTBUG-9350
and
https://bugreports.qt.io/browse/QTBUG-4465
On Windows, the child process inherits sockets and file-descriptors even inheritFileDescriptors is set to false
Seems that the bug was fixed in QT5
A discussion about the issue on an Oracle thread:
https://community.oracle.com/thread/1048626
TL;DR; The oracle server does not "know" that the client has disappeared.
Some solutions:
1.There is a terminated connection detection feature:
http://docs.oracle.com/cd/B19306_01/network.102/b14213/sqlnet.htm#sthref474
2.My advice is to try to implement a 'connection pool' if you use QOCI driver. Or you can use ODBC which has support for connection pooling.
Looks like main process didn't terminated successfully and awaits for child process termination in some place of finalization code before closing database connection.
From other side exceptional situation raised by abnormal termination of child process successfully propagated to parent process which starts finalization process and closes connection to Oracle.
So first suggestion is to check if child process properly reacts on kill() and terminate() calls, and even parent process try to terminate child in case of abnormal termination.

Simultaneous connection issue with boost SSL connection

Below pseudo code explains the situation I am facing
Server side
while (<some condition>)
{
// wait for SSL connection
acceptor.async_accept();
// wait until connection
io_service.run();
// perform handshake
ssl_socket.handhake();
// handshake successfully complete, start command manager thread
pthread_create();
io_service.reset();
// Go for the new connection waiting
}
What the problem here is I am able to connect two clients but not simultaneously.
1 connection arrives after which it takes 40-50 milliseconds for handshake and certificate verification and due to this reason any connection request in between fails.
Update:
Is there any way to stop listening client hello while handshaking is in progress?
I have to create new io_service instance for each loop as I might want to cancel the specific thread using io_service.stop() call. Does boost have any other option for the same?
The synchronous ssl_socket.handshake() will prevent additional connections from being accepted. Use ssl_socket.async_handshake() if you desire asynchronous behavior.
Also worth noting: you won't need a connection per-thread as that design won't scale beyond trivial examples.

ColdFusion Threads Remain in Thread Queue NOT_STARTED

I am using CFTHREAD on ColdFusion 8.
Occasionally I find that all the threads stop executing and remain with STATUS=NOT_STARTED
The server monitor tells me that there are no running requests, no running threads and an increasing number of queued threads.
The only way to recover is to restart the ColdFusion instance.
I only use threads in a handful of places. Some of the calls to CFTHREAD are JOINED - in this case I terminate any threads which have not completed within the timeout. Some of the calls to CFTHREAD are fire and forget.
Does anyone know why this might be happening?
Thanks,
William Bibby
In one of my application I already faced thread hanging issue. That's because, my thread was running some HTTP call or huge file downloading procedure, it was facing connection timeout problem.
Due to this thread hanging our server also becomes very busy because resources acquired by the running thread can't be released.
My Solution: Just check from how much time the thread is running. If it more than a specific interval then I was killing the thread by code.
You can use ColdFusion Admin API to kill a thread. If you want how to kill a thread using admin API then see here