-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Forbid the removal of the write block if the index is read-only #120648
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
Forbid the removal of the write block if the index is read-only #120648
Conversation
|
Pinging @elastic/es-distributed-indexing (Team:Distributed Indexing) |
henningandersen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good though I hope we can support removing one of two write blocks too? See comment.
| if (blocks.hasIndexBlock(index, block)) { | ||
| blocks.removeIndexBlock(index, block); | ||
| changed = true; | ||
| if (block.contains(ClusterBlockLevel.WRITE)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is too harsh. In case the index has both the read-only and the write block, it should be allowed to remove either.
In particular, if the user applied read-only on 8.x, upgraded and then want to update some settings, they should be allowed to add the write block and remove the read-only block.
I recognize this is also a flaw in the original code in that it removes the verified setting.
I could be ok to let this go in if we follow-up with the additional detail. But would prefer we do it in one go if it is not too hard.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is too harsh. In case the index has both the read-only and the write block, it should be allowed to remove either.
I agree, it makes sense.
In particular, if the user applied read-only on 8.x, upgraded and then want to update some settings, they should be allowed to add the write block and remove the read-only block.
I initially thought that updating both settings at once would not work because of the code allowing setting updates when there is a METADATA_WRITE block in place:
Lines 87 to 91 in 45ae071
| if (request.settings().size() == 1 && // we have to allow resetting these settings otherwise users can't unblock an index | |
| IndexMetadata.INDEX_BLOCKS_METADATA_SETTING.exists(request.settings()) | |
| || IndexMetadata.INDEX_READ_ONLY_SETTING.exists(request.settings()) | |
| || IndexMetadata.INDEX_BLOCKS_READ_ONLY_ALLOW_DELETE_SETTING.exists(request.settings())) { | |
| return null; |
but it seems that request.settings().size() == 1 does not always apply since the great setting refactoring here.
It looks like this refactoring introduced a change in the parenthesis impacting the conditions to bypass the check. Which will serve us today.
|
Ok, so it took me a couple of days to get this working with the subtleties of blocks updates. Thanks for your patience on this @henningandersen. I updated this PR (and #120647) to forbid the removal of the Since both I also changed the I largely updated the integration tests to to have a bit more randomization around blocks and closing/opening during upgrades. Note that there is still a bit missing for fully supporting closed indices (allowing a verified-before-close index to be upgraded without being marked as read-only first): I'll do this in follow ups. |
henningandersen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
| private static void verifyReadOnlyIndices(@Nullable Set<Index> readOnlyIndices, ClusterBlocks blocks) { | ||
| if (readOnlyIndices != null) { | ||
| for (Index readOnlyIndex : readOnlyIndices) { | ||
| if (blocks.indexBlocked(ClusterBlockLevel.WRITE, readOnlyIndex.getName()) == false) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this use the new hasIndexBlockLevel method to avoid interaction from global blocks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I pushed de6a0bd.
| closeIndex(restoredIndex); | ||
| ensureGreen(restoredIndex); | ||
|
|
||
| logger.debug("--> write API block can be removed on a closed index: INDEX_CLOSED_BLOCK already blocks writes"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we also check that if an index has both read-only and write block then we can remove one of them for an N-2 index?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reworked the testIndexUpgrade test to randomly add one or two of the blocks, and then remove one of them.
See 59e7acd
|
Thanks Henning |
Ensure that a
writeblock cannot be removed on a read-only compatible index in version N-2, while allowing to change aread_onlyblock into awriteblock if needed as well as closing/reopening such indices.Requires #120647 to be merged on
8.x.Relates ES-10320