When a write timeout occurs, the Java driver can be configured to call a RetryPolicy to allow clients flexibility in error handling.
The onWriteTimeout method is passed a single ConsistencyLevel argument, described as "the original consistency level of the write that timed out." This looks a bit sketchy since writes can set two kinds of consistency levels (CL and SCL), but the retry handler only gets informed about one.
When a write timeout occurs on a SCL=SERIAL write, the consistency level passed to onWriteTimeout is SERIAL. Retrying with the level given results in an InvalidQueryException.
The bug is reproduced in this simple java program:
When a write times out on the Paxos phase, retry with the consistency level of the previous attempt (not the serial CL).
Updated the built-in policies.
Added ConsistencyLevel.isSerial (JAVA-982)
Changed the code so that a retry with CL=null uses the CL of the last attempt, not the original one (in case a downgrading policy retries multiple times).