question

bdylan avatar image
bdylan asked Erick Ramirez answered

"Re-preparing already prepared query" warning during rolling release redeployment

I have the following cluster setup:
- 2 nodes
- cassandra-driver-core-3.11.0

And have encountered the following problem during the rolling release redeployment:

Cluster Re-preparing already prepared query is generally an anti-pattern and will likely affect performance. Consider preparing the statement only once. Query=...

Plenty of such messages were registered on the new nodes and the affected queries were unavailable through the driver client, though from the code these queries are prepared only once.

The release was as follows:

  1. 3rd node was introduced to the cluster
  2. 1nd node was asked to create a couple of new tables and did it successfully
  3. 3rd node tried to prepare queries for these new tables and entered in an infinite loop of above mentioned warnings
  4. 1st node was removed from the cluster
  5. 4th node was introduced to the cluster
  6. 4th node tried to prepare queries for these new tables and entered in infinite loop of above mentioned warnings
  7. 2nd node was removed from the cluster

It all continued up until next full redeploymen. And then queries were prepared successfully and everything worked well.

Anyone can give some clues as what could be misconfigured in my case?

java driver
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

Erick Ramirez avatar image
Erick Ramirez answered

Prepared statements are not replicated to all nodes in the cluster -- in the first instance, the driver sends the prepared statement to just one node to make sure it is fine then once the driver gets a successful reply from that node, the driver re-prepares the statement on the remaining nodes.

In your case where you're adding nodes, the driver has to re-prepare all the statements on the new nodes. This behaviour is normal which is why when the driver detects that a statement has been re-prepared, it just logs a WARN instead of an ERROR.

For details, see Prepared statements in Java driver 3.11. Cheers!

Share
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.