DESCRIPTION

JCBC-809: Named Prepared Statement retry handling

Motivation:
-----------
Since the cache of plans is not (yet) distributed, we want to be able to
intelligently retry (re-prepare the statement) if the name is not known.
We also want to give a coherent name to our prepared statements in order
to have the same names on all nodes.

Modifications
-------------
This change modifies the query() method so it will detect a
PreparedQuery and chain retry logic to it: if the RetryStrategy is best
effort, it will peek into the errors() stream and detect 4040 (name is
not found), in which case it will do a prepare again.

Note that this approach is prone to problems on a cluster with multiple
query nodes, and could even lead to livelock if the retry was performed
continuously. This is why for now we only attempt retry once.

Tests have been added and amended, but integration testing is not
entirely possible while there's no mean of removing a prepared statement
from the server's cache.

Results
-------
All tests pass, a PreparedQuery is retried once if the N1QL service says
it doesn't know about a prepared statement with that particular name.

Change-Id: I6622aa6da67df0a61ccb89c7bded18f0d6c30899


COMMENTS

author: Estrella Humphrey
date: 2015-07-09 17:42:33.277000000

Uploaded patch set 1.

-------------------------------------
author: Estrella Humphrey
date: 2015-07-09 17:46:32.153000000

Patch Set 1: Code-Review-2 Verified+1

verified to work on 1 node cluster, please comment but don't submit until discussions around retry next week with Kamren Stephens and Gerald.

-------------------------------------
author: Tate Garrett
date: 2015-07-22 13:23:56.394000000

Change has been successfully cherry-picked as f0aa8d2c70e99d003b14be9859dce83282c1b898

-------------------------------------
