Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the creation of the primary index in Couchbase container retryable #9527

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -685,28 +685,40 @@ private void createBuckets() {

if (bucket.hasPrimaryIndex()) {
if (enabledServices.contains(CouchbaseService.QUERY)) {
@Cleanup
Response queryResponse = doHttpRequest(
QUERY_PORT,
"/query/service",
"POST",
new FormBody.Builder()
.add("statement", "CREATE PRIMARY INDEX on `" + bucket.getName() + "`")
.build(),
true
);
timePhase(
"createBucket:" + bucket.getName() + ":createPrimaryIndex",
() -> {
Unreliables.retryUntilSuccess(
1,
TimeUnit.MINUTES,
() -> {
@Cleanup
Response queryResponse = doHttpRequest(
QUERY_PORT,
"/query/service",
"POST",
new FormBody.Builder()
.add("statement", "CREATE PRIMARY INDEX on `" + bucket.getName() + "`")
.build(),
true
);

try {
checkSuccessfulResponse(
queryResponse,
"Could not create primary index for bucket " + bucket.getName()
);
} catch (IllegalStateException ex) {
// potentially ignore the error, the index will be eventually built.
if (!ex.getMessage().contains("Index creation will be retried in background")) {
throw ex;
try {
checkSuccessfulResponse(
queryResponse,
"Could not create primary index for bucket " + bucket.getName()
);
} catch (IllegalStateException ex) {
// potentially ignore the error, the index will be eventually built.
if (!ex.getMessage().contains("Index creation will be retried in background")) {
throw ex;
}
}
return null;
}
);
}
}
);

timePhase(
"createBucket:" + bucket.getName() + ":primaryIndexOnline",
Expand Down