The Mapper should not prepare queries synchronously.

Description

The Object Mapper does a lazy preparation of queries when a client wants to fetch a mapped entity for the first time. However, the preparation of these query is made synchronously, this call blocks and returns the prepared statement to execute later to get the proper information for this mapped instance.

However, my theory is that this comes in conflict when the cluster is initialised asynchronously with Cluster#connectAsync(), since this method returns immediately while the cluster is not yet completely initialized, when the mapper is going to try to prepare, the calling thread will be blocked, this causes a lock and only a Client timeout will make it go out of this lock. There's a code example below to reproduce the issue. To use against a single node cluster.

We should prepare the statements asynchronously, and keep references to ListenableFuture<PreparedStatement> instead of PreparedStatement in the preparedQueries map.

Environment

C* 3.0.0

Pull Requests

None

Status

Assignee

Alexandre Dutra

Reporter

Kevin Gallardo

Labels

None

PM Priority

None

Reproduced in

3.0.0

Affects versions

Fix versions

Pull Request

None

Doc Impact

None

Size

None

External issue ID

None

External issue ID

None

Components

Sprint

Priority

Major
Configure