cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tyler Hobbs <ty...@datastax.com>
Subject Re: Caching the PreparedStatement (Java driver)
Date Fri, 15 May 2015 19:11:52 GMT
On Fri, May 15, 2015 at 12:02 PM, Ajay <ajay.garga@gmail.com> wrote:

>
> But I am also not sure of what happens when a cached prepared statement is
> executed after cassandra nodes restart. Does the server prepared statements
> cache is persisted or in memory?.


For now, it's just in memory, so they are lost when the node is restarted.


> If it is in memory, how do we handle stale prepared statement in the cache?


If a prepared statement ID is used that Cassandra doesn't recognize (e.g.
after a node restart), it responds with a specific error to the driver.
When the driver sees this error, it automatically re-prepares the statement
against that node using the statement info from its own cache.  After the
statement has been re-prepared, it attempts to execute the query again.
This all happens transparently, so your application will not even be aware
of it (aside from an increase in latency).

There are plans to persist prepared statements in a system table:
https://issues.apache.org/jira/browse/CASSANDRA-8831


-- 
Tyler Hobbs
DataStax <http://datastax.com/>

Mime
View raw message