Here’s the complete solution addressing optimistic concurrency control, ETag handling, and conflict resolution:
Optimistic Concurrency Control:
Windchill’s ETag includes version iteration, timestamp, and internal state hash. Background processes (indexing, cache sync, lifecycle evaluators) can modify the state hash without version changes. Implement retry logic with exponential backoff:
// Pseudocode - Robust update with retry:
1. Set max_retries = 3, retry_delay = 500ms
2. For attempt in 1 to max_retries:
- GET document and extract fresh ETag
- Immediately PATCH with If-Match header
- If 200 OK: break and return success
- If 409 Conflict: wait retry_delay, double delay
- If 412 Precondition Failed: version changed, abort
3. If all retries fail: log conflict and queue for manual review
ETag/Version Headers:
Always fetch ETag immediately before update and include both If-Match and X-PTC-UpdateMode headers:
PATCH /DocMgmt/Documents('12345')
If-Match: "v2.1708523400000"
X-PTC-UpdateMode: optimistic
Content-Type: application/json
The X-PTC-UpdateMode header tells Windchill to use strict ETag validation rather than fallback to last-write-wins behavior.
Conflict Resolution Strategies:
-
Retry with Fresh ETag (80% of conflicts resolve this way):
- Fetch current state
- Reapply your changes
- Submit with new ETag
-
Merge Strategy (for partial updates):
- GET current document state
- Merge your changes with current values
- PATCH merged result
-
Version-Based Resolution (for critical conflicts):
- Check if version iteration changed (v2 → v3)
- If yes: true concurrent edit, require manual review
- If no: internal state change, safe to retry
-
Pessimistic Lock Fallback (for sequential updates):
- POST to /Documents(‘12345’)/Actions/CheckOut
- Perform updates on working copy
- POST to /Actions/CheckIn with updated content
- This prevents concurrent modifications entirely
For your automation scenario, I recommend implementing retry logic first. If conflicts persist, consider whether your updates need strict concurrency control. For metadata-only changes that don’t affect version content, using X-PTC-IgnoreVersionCheck with a custom header like X-Client-UpdateToken can provide simpler conflict detection at the application level.
Monitor conflict rates over time. If you see >10% of updates hitting 409, investigate whether scheduled jobs or integrations are causing unnecessary document touches. Sometimes disabling real-time indexing for bulk update windows reduces conflicts significantly.
This draft is based on general Windchill knowledge. It has not been verified against your specific version and environment. Practitioners: verify the steps and share your experience below.