Details
-
Bug
-
Resolution: Fixed
-
Major
-
None
-
None
-
None
-
0
Description
Looking for a good solution to "Fail Fast" in the below scenario regarding using Named Prepared Queries from the SDK. We are running queries using named prepared statements instead of using .adhoc(false) from the .net SDK. This works fine when the prepared statement exists. If the prepared does not exist, we catch the exception - prepare it - then retry. The problem, is that the error code 4040 is handled as a retryable error. https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/n1ql-error-codes.html#4xxx-codes-plan
https://docs.couchbase.com/dotnet-sdk/current/howtos/error-handling.html#retryreasons
Running QueryAsync() of simple execute prepared garnishes the following exception when not exists on the server. Execute sampleV1_0;
From Server: [ { "code": 4040, "msg": "No such prepared statement: sampleV1_0, context: unset", "query": "Execute sampleV1_0" } ]
The default retry strategy causes the failed query to execute 10 times before allowing me to proceed and attempt to generate the prepared statement. this causes some performance issues for the app - and while it does currently recover itself after the retries, I would like to tackle the perf issue if possible.
Should I implement a custom RetryStrategy and try to leverage the volatile RetryReason enum value RetryReason.QueryPreparedStatementFailure? Or is there a code change to the SDK that I could possibly assist with to avoid the retry for this error code? Optionally... if it is simply not a recommended approach. I can consider altering our logic to no longer leverage the named prepared statements in this way. This was the original strategy suggested by prof serv when we built our first service for optimal performance.
This issue is created from discussion on the Community Discord.
https://discord.com/channels/915294689681362954/1069752007793062058