4

After adding a pair of columns in schema, I want to select them via select *. Instead select * returns old set of columns and none new.

By documentation recommendation, I use {prepare: true} to smooth JavaScript floats and Cassandra ints/bigints difference (I don't really need the prepared statement here really, it is just to resolve this ResponseError : Expected 4 or 0 byte int issue and I also don't want to bother myself with query hints).

So on first execution of select * I had 3 columns. After this, I added 2 columns to schema. select * still returns 3 columns if is used with {prepare: true} and 5 columns if used without it.

I want to have a way to reliably refresh this cache or make cassandra driver prepare statements on each app start.

I don't consider restarting database cluster a reliable way.

Community
  • 1
  • 1
Igor Loskutov
  • 2,157
  • 2
  • 20
  • 33
  • You can [clear the prepared statement metadata](https://datastax-oss.atlassian.net/browse/NODEJS-45) using: `client.metadata.clearPrepared()` – jorgebg Mar 02 '15 at 08:05

1 Answers1

5

This is actually an issue in Cassandra that was fixed in 2.1.3 (CASSANDRA-7910). The problem is that on schema update, the prepared statements are not evicted from the cache on the Cassandra side. If you are running a version less than 2.1.3 (which is likely since 2.1.3 was released last week), there really isn't a way to work around this unless you create another separate prepared statement that is slightly different (like extra spaces or something to cause a separate unique statement).

When running with 2.1.3 and changing the table schema, C* will properly evict the relevant prepared statements from the cache, and when the driver sends another query using that statement, Cassandra will respond with an 'UNPREPARED' message, which should provoke the nodejs driver to reprepare the query and resend the request for you.

On the Node.js driver, you can programatically clear the prepared statement metadata:

client.metadata.clearPrepared(); 
jorgebg
  • 6,560
  • 1
  • 22
  • 31
Andy Tolbert
  • 11,418
  • 1
  • 30
  • 45