sheetalshah1007 opened a new pull request, #729:
URL: https://github.com/apache/atlas/pull/729
## [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**:
```bash
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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]