Skip to content

ATLAS-5375: Fix stale PUT response for /api/atlas/v2/relationship block/unblock propagation - #729

Open
sheetalshah1007 wants to merge 1 commit into
apache:masterfrom
sheetalshah1007:ATLAS-5375
Open

ATLAS-5375: Fix stale PUT response for /api/atlas/v2/relationship block/unblock propagation#729
sheetalshah1007 wants to merge 1 commit into
apache:masterfrom
sheetalshah1007:ATLAS-5375

Conversation

@sheetalshah1007

@sheetalshah1007 sheetalshah1007 commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

[ATLAS-5375] Fix stale PUT response for /api/atlas/v2/relationship block/unblock propagation

Problem

When atlas.tasks.enabled=true, relationship PUTs that change propagateTags or blockedPropagatedClassifications queue a background propagation task. Previously, the HTTP 200 body could return stale edge state (blockedPropagatedClassifications, propagatedClassifications) because the response did not reflect the requested block/direction change while entity tag updates ran asynchronously.

Task GUIDs stored on the relationship edge (__pendingTasks) had two additional issues:

  • They were not exposed in relationship JSON, so clients could not see in-flight work.
  • They often did not clear after COMPLETE/FAILED because in-place updates to the edge list property were not persisted (cleanup logic ran, but the graph still held stale GUIDs).

Solution

This patch updates the relationship edge synchronously on PUT and keeps downstream entity tag propagation in the background task.

Key changes

  1. Synchronous edge updates: Refactored DeleteHandlerV1.updateTagPropagations() to write edge properties (propagateTags, blocked IDs) before the API returns. Tasks are queued only when propagateTags or the blocked list actually changes (no-op PUTs skip task queue).

  2. Pre-change state in task params: ClassificationTask passes oldTagPropagation and oldBlockedClassifications into the worker so entity tag updates use pre-PUT edge state. The worker does not assume the edge is still in its old state (edge is already updated).

  3. API visibility for pendingTasks: Added read-only pendingTasks on AtlasRelationship. EntityGraphRetriever maps edge __pendingTasks into JSON when non-empty.

  4. Edge list-property persistence fix: AtlasGraphUtilsV2.addItemToListProperty / removeItemFromListProperty now use copy-on-write (new ArrayList + setListProperty) so queue/remove of task GUIDs persists and pendingTasks clears after COMPLETE/FAILED.

Testing

  • Extended ClassificationPropagationWithTasksTest and updated related task tests (ClassificationPropagationTasksTest, ClassificationTaskTest, ClassificationPropagateTaskFactoryTest).
  • 56 repository tests pass on Java 8 and Java 17:
mvn -pl repository -Dtest=ClassificationPropagationWithTasksTest,ClassificationPropagationTasksTest,ClassificationTaskTest,ClassificationPropagateTaskFactoryTest test

Coverage includes:

  • Unblock/block PUT and GET show updated edge state before task completes
  • pendingTasks populated while work is in flight; cleared after COMPLETE
  • Entity propagation outcomes after background task
  • propagateTags change wins over blocked change in the same PUT (if/else)

Optional manual check: dev-support/atlas-scripts/atlas5375_pr_review_test.sh

Compatibility & API impact

  • No breaking changes — additive read-only pendingTasks field only.
  • pendingTasks omitted when empty (@JsonInclude(NON_NULL)); treat missing field as none in flight.
  • Response shape: PUT returns relationship at top level; GET wraps in "relationship".
  • Task status: GET /api/atlas/admin/tasks?guids={guid} (admin).
  • Legacy in-flight tasks without new params supported via isLegacyTask.
  • propagateTags required on PUT — omitting it retains legacy NPE risk (out of scope).

Trade-off

Edge metadata commits before entity tags. If the background task fails after retries, edge rules may differ from downstream classifications; recover by re-PUT, admin task DELETE + re-PUT, or manual tag correction.


Attachments

Design doc: ATLAS-5375-design-document.md — implementation notes for reviewers (problem/flow, API behavior, tests, trade-offs). Reference only; not part of the runtime deliverable.

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.

1 participant