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

Add support for append only indices #17039

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

RS146BIJAY
Copy link
Contributor

@RS146BIJAY RS146BIJAY commented Jan 16, 2025

Description

Adding support for Append only indices where we are disabling any form of updates and deletes on the index. We are also preventing passing a custom doc id for bulk indexing requests. Append only indices will be supported through a configurable setting. If this setting is enabled, all update and delete operations on the index (UPDATE, DELETE, UPSERT, UPDATE BY QUERY, DELETE BY QUERY, etc,) will be blocked.

Related Issues

#12886

Check List

  • Functionality includes testing.
  • API changes companion pull request created, if applicable.
  • Public documentation issue/PR created, if applicable.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Copy link
Contributor

❌ Gradle check result for 38061f7: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@RS146BIJAY RS146BIJAY marked this pull request as ready for review January 17, 2025 10:31
@RS146BIJAY RS146BIJAY changed the title Adding support for append only indices Add support for append only indices Jan 17, 2025
Copy link
Contributor

❌ Gradle check result for 7af2713: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Copy link
Member

@mgodwan mgodwan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If indexing into lucene ever causes the version to be greater than 1, should we fail the shard?

*
* @opensearch.internal
*/
public class IndexingRetryException extends RuntimeException {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets extend from OpenSearchException

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack.

@@ -584,7 +584,7 @@ public static IndexMergePolicy fromString(String text) {
*/
public static final Setting<Boolean> INDEX_UNREFERENCED_FILE_CLEANUP = Setting.boolSetting(
"index.unreferenced_file_cleanup.enabled",
true,
false,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we making this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non intentional change. Will correct it.

SETTING_INDEX_APPEND_ONLY_ENABLED,
false,
Property.IndexScope,
Property.Final
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we allow it to be changed from true to false at some later point in the future? I'm ok to have it as final for now but wondering if there are use-cases which require such support.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually true to false can be supported. But false to true should be blocked

@@ -538,6 +539,11 @@ protected void doRun() {
if (docWriteRequest == null) {
continue;
}

if (addFailureIfIndexAppendOnlyAndOpsDeleteOrUpdate(docWriteRequest, i, concreteIndices, metadata)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be checked for only after confirming index is not available through addFailureIfIndexIsUnavailable?
This will help short circuit for index unavailable cases faster.

}

final IndexMetadata indexMetadata = metadata.index(concreteIndex);
if (indexMetadata.isAppendOnlyIndex() == true) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove == true

} else if (request.id() != null && request.opType() == DocWriteRequest.OpType.INDEX) {
ValidationException exception = new ValidationException();
exception.addValidationError(
"Operation [" + request.opType() + "] is not allowed with a custom doc id " + request.id()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add to the message that the reason validation is failing because append only setting is set to true?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack.

if ((request.opType() == DocWriteRequest.OpType.UPDATE || request.opType() == DocWriteRequest.OpType.DELETE)) {
ValidationException exception = new ValidationException();
exception.addValidationError(
"Operation [" + request.opType() + "] is not allowed for append only index " + request.index()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add to the message that the reason validation is failing because append only setting is set to true?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack.

@@ -756,6 +762,44 @@ public void onTimeout(TimeValue timeout) {
});
}

private boolean addFailureIfIndexAppendOnlyAndOpsDeleteOrUpdate(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add UTs for this in TransportBulkActionTests?

Comment on lines +157 to +168
response = client().prepareBulk().add(client().prepareUpdate("index", "0").setDoc("foo", "updated")).get();
assertThat(
response.getItems()[0].getFailureMessage(),
containsString("Operation [UPDATE] is not allowed for append only index index;")
);

response = client().prepareBulk().add(client().prepareDelete("index", "0")).get();
assertThat(
response.getItems()[0].getFailureMessage(),
containsString("Operation [DELETE] is not allowed for append only index index;")
);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we testing update/delete in retry test?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These calls will be blocked at the transport layer itself. I was thinking around covering different scenarios. Will remove this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants