As posted here, I think your issue is that you're sharing the driver's session object across threads. This is undefined behavior as mentioned in the API docs:
Session creation is a lightweight operation and sessions are not thread safe .
The code snippets you've shared don't really show how the session is created, which makes it hard to pinpoint at where things are going wrong.