Skip to content

Controller: finish a resource-definition delete after a successful resource retry - #577

Open
webdock-cloudv2 wants to merge 2 commits into
LINBIT:masterfrom
webdock-io-admin:pr/linstor-server-26-rd-delete-after-retry
Open

webdock-cloudv2 wants to merge 2 commits into
LINBIT:masterfrom
webdock-io-admin:pr/linstor-server-26-rd-delete-after-retry

Conversation

@webdock-cloudv2

Copy link
Copy Markdown

Fixes #574

Problem

A resource-definition delete whose first answer from a satellite is an error leaves the resource definition flagged DELETE with no resources. It stays that way until a satellite reconnects or someone issues the delete again. In our case the error was a busy zfs destroy (#545): the satellite destroyed the zvol on its next run, and the controller's retry removed the resource, but not the resource definition.

Cause

  • CtrlRscDfnDeleteApiCallHandler.deleteResourceDefinitionInTransaction returns truncate(...).concatWith(deleteData).onErrorResume(DelayedApiRcException -> empty). The satellite error ends the truncate, so deleteData is skipped and the error is swallowed.
  • CtrlSatelliteUpdateCaller.updateResource puts the failed resource into RetryResourcesTask with the per-resource next step only.
  • The retry removes the resource, and nothing removes the resource definition. resourceDefinitionConnected restarts the delete only on a satellite reconnect.

Change

  • CtrlRscDfnDeleteApiCallHandler.finishDeleteIfFlagged(rscName): under the resource-definition map's write lock, if the resource definition exists and is flagged DELETE, run deleteResourceDefinitionInTransaction. That is the same path as the reconnect hook and a re-issued delete.
  • RetryResourcesTask calls it after the satellite's answer to a retry and the stored next step, if that answer had no error entries. A retry that fails again leaves the resource definition alone.
  • The handler is resolved lazily through the Injector, not as a constructor dependency. The handler depends on this task (through truncate and the satellite update caller), and even a Provider would make Guice require the handler's whole graph wherever the task is bound, for example in reduced test modules.

Notes for review

  • Unchanged, existing behaviour. The retry runs its stored next step even when the satellite's answer to the retry has errors: .concatWith(nextStep) is not gated. The controller can then remove a resource whose backing device still exists on the satellite. This change gates only its own step. Gating the next step would touch more callers (toggle-disk, activation and so on), so we kept it separate.
  • Empty answer. An answer with no entries counts as success. If the satellite was not done, the re-run delete fails again, the same as a manual re-issue.
  • Errors of the finish step. Its result goes where the retry's results always went (subscribed and dropped), so its errors are not reported separately.
  • Concurrent re-issue. If a user re-issues the delete at the same time, both runs take the write lock one after the other. The second finds the resource definition gone and does nothing.
  • Any retried resource. A resource definition flagged DELETE means its delete was requested. So finishing it from a retry of any of its resources (also after a per-node delete or a toggle-disk retry) is the intended outcome.

Tests

On this branch, based on master e1d9994:

  • assemble :controller:test :test plus checkstyle (main and test, controller and root): BUILD SUCCESSFUL.
    • Controller: 102 tests. Root: 2,256 tests. 0 failures.
    • No checkstyle errors and no new main-code warnings.
  • New RetryResourcesTaskFinishDeleteTest (3), with a mocked peer and handler and the satellite answer serialized as protobuf ApiCallResponse:
    • a successful retry runs the next step, then finishes the delete;
    • a retry answered with "dataset is busy" (FAIL_UNKNOWN_ERROR) does not touch the resource definition;
    • a peer error ends the retry without finishing.
  • CtrlRscDfnDeleteApiCallHandlerTest +3: a flagged empty resource definition is deleted, an unflagged one is kept, and a missing one is a no-op.

Results on our dev cluster

These are from the same change on a 1.35.3 base, as posted on #574: 21 resource definitions (a source and 20 --use-zfs-clone clones) on two ZFS-thin nodes, deleted one by one.

without this change (same day) with this change
deletes whose first satellite answer was "dataset is busy" 14 2 of 21
of those, left in DELETE with no resources 14 of 14, until the delete was re-issued 0 of 2
busy error → resource definition removed by the controller (re-issue needed) 27.7 s and 28.0 s (first retry round)
re-issued deletes needed 14 0
orphaned zvols afterwards 0

The sample of busy-first deletes with the change is small (2).


Prepared with AI assistance at Webdock; reviewed and tested by Arni from Webdock

🤖 Generated with Claude Code

https://claude.ai/code/session_01MdF8CnRMuczotcRYmButcR

webdock-cloudv2 and others added 2 commits November 11, 2026 07:38
…source retry

A resource-definition delete whose first answer from a satellite is an error
(e.g. "dataset is busy" from zfs destroy) left the resource definition flagged
DELETE with no resources, until a satellite reconnected or the delete was
issued again:

- deleteResourceDefinitionInTransaction returns truncate(...).concatWith(
  deleteData).onErrorResume(DelayedApiRcException -> empty): the satellite
  error ends the truncate, so deleteData is skipped and the error swallowed.
- CtrlSatelliteUpdateCaller puts the failed resource into RetryResourcesTask
  with the per-resource next step only. The retry removes the resource, and
  nothing removes the resource definition; only resourceDefinitionConnected
  restarts the delete, on a satellite reconnect.

CtrlRscDfnDeleteApiCallHandler.finishDeleteIfFlagged(rscName) runs the same
delete as the reconnect hook and a re-issued delete, under the resource
definition map's write lock, if the resource definition still exists and is
flagged DELETE. RetryResourcesTask calls it after the satellite's answer to
a retry and the stored next step, if that answer had no error entries; a
retry that fails again leaves the resource definition alone. The handler is
resolved lazily through the injector, because it depends on this task.

Refs: LINBIT#574

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MdF8CnRMuczotcRYmButcR
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MdF8CnRMuczotcRYmButcR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant