|
27 | 27 | import static org.springframework.data.couchbase.config.BeanNames.REACTIVE_COUCHBASE_TEMPLATE;
|
28 | 28 | import static org.springframework.data.couchbase.util.Util.waitUntilCondition;
|
29 | 29 |
|
| 30 | +import com.couchbase.client.core.retry.BestEffortRetryStrategy; |
| 31 | +import com.couchbase.client.core.retry.RetryStrategy; |
30 | 32 | import okhttp3.Credentials;
|
31 | 33 | import okhttp3.FormBody;
|
32 | 34 | import okhttp3.OkHttpClient;
|
@@ -161,10 +163,27 @@ public static void setupScopeCollection(Cluster cluster, String scopeName, Strin
|
161 | 163 |
|
162 | 164 | // the call to createPrimaryIndex takes about 60 seconds
|
163 | 165 |
|
164 |
| - try { |
165 |
| - block(createPrimaryIndex(cluster, config().bucketname(), scopeName, collectionName)); |
166 |
| - } catch (Exception e) { |
167 |
| - e.printStackTrace(); |
| 166 | + // sometimes fails with : |
| 167 | + // com.couchbase.client.core.error.IndexFailureException: The server reported an issue with the underlying index |
| 168 | + // {"completed":true,"coreId":"0xbbef22aa00000003","errors":[{"code":12003,"message":"Keyspace not found in CB |
| 169 | + // datastore: default:cfc84bb8-ab0e-433e-a1af-812d51fa8855.my_scope.my_collection2","retry":false}], |
| 170 | + // "httpStatus":500,"idempotent":false,"lastDispatchedFrom":"127.0.0.1:49908","lastDispatchedTo":"127.0.0.1:8093", |
| 171 | + // "requestId":58,"requestType":"QueryRequest","retried":0,"service": |
| 172 | + // {"operationId":"04b28225-2b0f-4d2c-943b-330ac637ecd8","statement":"CREATE PRIMARY INDEX ON |
| 173 | + // default:`cfc84bb8-ab0e-433e-a1af-812d51fa8855`.`my_scope`.`my_collection2`","type":"query"}, |
| 174 | + // "timeoutMs":300000,"timings":{"dispatchMicros":746,"totalDispatchMicros":746,"totalMicros":1636}} |
| 175 | + |
| 176 | + for (int i = 0; i < 10; i++) { |
| 177 | + try { |
| 178 | + sleepMs(100); |
| 179 | + block(createPrimaryIndex(cluster, config().bucketname(), scopeName, collectionName)); |
| 180 | + break; |
| 181 | + } catch (Exception e) { |
| 182 | + System.err.println(e); |
| 183 | + if (i > 5) { |
| 184 | + e.printStackTrace(); |
| 185 | + } |
| 186 | + } |
168 | 187 | }
|
169 | 188 |
|
170 | 189 | waitUntilCondition(
|
@@ -201,7 +220,7 @@ protected static void waitForQueryIndexerToHaveBucket(final Cluster cluster, fin
|
201 | 220 | private static void createAndDeleteBucket() {
|
202 | 221 | final OkHttpClient httpClient = new OkHttpClient.Builder().connectTimeout(30, TimeUnit.SECONDS)
|
203 | 222 | .readTimeout(30, TimeUnit.SECONDS).writeTimeout(30, TimeUnit.SECONDS).build();
|
204 |
| - String hostPort = connectionString().replace("11210", "8091").replace("11207", "18091"); |
| 223 | + String hostPort = connectionString().split("=")[0].replace("11210", "8091").replace("11207", "18091"); |
205 | 224 | String protocol = hostPort.equals("18091") ? "https" : "http";
|
206 | 225 | String bucketname = UUID.randomUUID().toString();
|
207 | 226 | try {
|
|
0 commit comments