Skip to content

Conversation

@DaveCTurner
Copy link
Contributor

@DaveCTurner DaveCTurner commented May 9, 2025

Today there are various mechanisms to prevent writes to readonly
repositories, but they are scattered across the snapshot codebase and do
not obviously prevent writes in all possible circumstances; it'd be easy
to add a new operation on a repository that does not check the readonly
flag in quite the right way.

This commit adds much tighter checks which cannot be circumvented:

  • Do not allow to start an update of the root index-N blob if the
    repository is marked as readonly in the cluster state.

  • Conversely, do not allow the readonly flag to be set if an update of
    the root index-N blob is in progress.

  • Establish the invariant that we never create a
    SnapshotsInProgress$Entry, SnapshotDeletionsInProgress$Entry, or
    RepositoryCleanupInProgress$Entry if the repository is marked as
    readonly in the cluster state.

Closes #93575

Today there are various mechanisms to prevent writes to readonly
repositories, but they are scattered across the snapshot codebase and do
not obviously prevent writes in all possible circumstances; it'd be easy
to add a new operation on a repository that does not check the readonly
flag in quite the right way.

This commit adds much tighter checks which cannot be circumvented:

- Do not allow to start an update of the root `index-N` blob if the
  repository is marked as readonly in the cluster state.

- Conversely, do not allow the readonly flag to be set if an update of
  the root `index-N` blob is in progress.

- Establish the invariant that we never create a
  `SnapshotsInProgress$Entry`, `SnapshotDeletionsInProgress$Entry`, or
  `RepositoryCleanupInProgress$Entry` if the repository is marked as
  readonly in the cluster state.
@DaveCTurner DaveCTurner added >non-issue :Distributed Coordination/Snapshot/Restore Anything directly related to the `_snapshot/*` APIs v8.19.0 v9.1.0 labels May 9, 2025
@DaveCTurner DaveCTurner marked this pull request as ready for review May 9, 2025 11:53
@DaveCTurner DaveCTurner requested a review from ywangd May 9, 2025 11:53
@elasticsearchmachine elasticsearchmachine added the Team:Distributed Coordination Meta label for Distributed Coordination team label May 9, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-distributed-coordination (Team:Distributed Coordination)

@DaveCTurner DaveCTurner requested a review from DiannaHohensee May 9, 2025 11:54
Copy link
Member

@ywangd ywangd left a comment

Choose a reason for hiding this comment

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

LGTM

@DaveCTurner DaveCTurner added auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) auto-backport Automatically create backport pull requests when merged labels May 12, 2025
@elasticsearchmachine elasticsearchmachine merged commit b11327e into elastic:main May 12, 2025
17 checks passed
@DaveCTurner DaveCTurner deleted the 2025/05/09/blobstore-readonly-protections branch May 12, 2025 23:00
@elasticsearchmachine
Copy link
Collaborator

💔 Backport failed

Status Branch Result
8.19 Commit could not be cherrypicked due to conflicts

You can use sqren/backport to manually backport by running backport --upstream elastic/elasticsearch --pr 127964

benchaplin pushed a commit to benchaplin/elasticsearch that referenced this pull request May 20, 2025
Today there are various mechanisms to prevent writes to readonly
repositories, but they are scattered across the snapshot codebase and do
not obviously prevent writes in all possible circumstances; it'd be easy
to add a new operation on a repository that does not check the readonly
flag in quite the right way.

This commit adds much tighter checks which cannot be circumvented:

- Do not allow to start an update of the root `index-N` blob if the
  repository is marked as readonly in the cluster state.

- Conversely, do not allow the readonly flag to be set if an update of
  the root `index-N` blob is in progress.

- Establish the invariant that we never create a
  `SnapshotsInProgress$Entry`, `SnapshotDeletionsInProgress$Entry`, or
  `RepositoryCleanupInProgress$Entry` if the repository is marked as
  readonly in the cluster state.

Closes elastic#93575
DaveCTurner added a commit to DaveCTurner/elasticsearch that referenced this pull request May 22, 2025
Today there are various mechanisms to prevent writes to readonly
repositories, but they are scattered across the snapshot codebase and do
not obviously prevent writes in all possible circumstances; it'd be easy
to add a new operation on a repository that does not check the readonly
flag in quite the right way.

This commit adds much tighter checks which cannot be circumvented:

- Do not allow to start an update of the root `index-N` blob if the
  repository is marked as readonly in the cluster state.

- Conversely, do not allow the readonly flag to be set if an update of
  the root `index-N` blob is in progress.

- Establish the invariant that we never create a
  `SnapshotsInProgress$Entry`, `SnapshotDeletionsInProgress$Entry`, or
  `RepositoryCleanupInProgress$Entry` if the repository is marked as
  readonly in the cluster state.

Closes elastic#93575

Backport of elastic#127964 to `8.19`
elasticsearchmachine pushed a commit that referenced this pull request May 22, 2025
Today there are various mechanisms to prevent writes to readonly
repositories, but they are scattered across the snapshot codebase and do
not obviously prevent writes in all possible circumstances; it'd be easy
to add a new operation on a repository that does not check the readonly
flag in quite the right way.

This commit adds much tighter checks which cannot be circumvented:

- Do not allow to start an update of the root `index-N` blob if the
  repository is marked as readonly in the cluster state.

- Conversely, do not allow the readonly flag to be set if an update of
  the root `index-N` blob is in progress.

- Establish the invariant that we never create a
  `SnapshotsInProgress$Entry`, `SnapshotDeletionsInProgress$Entry`, or
  `RepositoryCleanupInProgress$Entry` if the repository is marked as
  readonly in the cluster state.

Closes #93575

Backport of #127964 to `8.19`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-backport Automatically create backport pull requests when merged auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) :Distributed Coordination/Snapshot/Restore Anything directly related to the `_snapshot/*` APIs >non-issue Team:Distributed Coordination Meta label for Distributed Coordination team v8.19.0 v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BlobStoreRepository#readOnly doesn't update with repo metadata changes

3 participants