DESCRIPTION

JCBC-829: Retry logic for prepared statements execution

Motivation:
-----------
Execution of queries marked as no ad-hoc are implemented through
prepared statements and a local cache of execution plans.
However, such executions should be made more resilient to a few N1QL
side errors by repreparing and re-executing once.

Modifications:
--------------
QueryExecutor's dispatchPrepared now has a retry logic in place. It will
peek into the result of an EXECUTE (in the N1QL sense, corresponding to
the executePrepared method) and redo a PREPARE followed by EXECUTE if
there's a retry-warranting error.

This is only done once, but is active both if the statement is in cache
or not.

QueryExecutor has been reworked in order to allow unit testing. Unit
tests have been added that verify various scenarios around prepared
statements, cache and retry.

Results:
--------
Non ad-hoc queries are now retried once when the executed plan is
determined to be outdated (errors 4050, 4070 and some 5000s).
QueryExecutor unit tests pass.

Change-Id: Iffe03bbbe3f760ff20964a71f44ff1b6d575d115
Reviewed-on: http://review.couchbase.org/54592
Tested-by: Estrella Humphrey xxx@xxx.xxx
Reviewed-by: Natasha Sullivan xxx@xxx.xxx


COMMENTS

author: Tate Garrett
date: 2015-08-21 07:39:37.097000000

Change has been successfully cherry-picked as 299f38383c808bb8b180e00cca1d340f39f0dbe5

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