RocMarshal commented on PR #30062:
URL: https://github.com/apache/flink/pull/30062#issuecomment-7119454474

   Thanks @chenzihao5 for the patch.
   
   I ran a first pass locally with some AI tooling — hope it helps:
   
   
   The issues described in FLINK-41286 is only partially resolved. Sharing the 
task registry fixes waiting for application jobs whose detail tasks are already 
registered. Startup-time 404 responses and other concurrency issues remain.
   
   1. **Application jobs can still return 404 before discovery or task 
registration.**
   
      On-demand discovery only checks `<refreshDir>/<jobId>` and does not 
search application directories. A request arriving before the application scan 
discovers the job therefore returns a missing resource.
   
      There is also a window between publishing the job metadata and 
registering its Future. Requests arriving during that window find no task to 
wait for.
   
      Both cases were reproduced with FILE and ROCKSDB.
   
   2. **Task registration and removal are not atomic.**
   
      `lazyProcessJobArchive()` submits the task before inserting its Future 
into the registry. Its completion handler unconditionally calls `remove(jobId)`.
   
      A canceled task that has not exited can remove the registration of a 
replacement task. Requests then stop waiting even though the replacement is 
still running. A sufficiently fast task can also finish before registration, 
leaving a completed Future in the registry.
   
      The replacement-removal race was reproduced with both backends. Using 
ConcurrentHashMap does not make these compound operations atomic.
   
   3. **Canceled tasks can recreate deleted job details.**
   
      `cancel(true)` does not guarantee that an in-flight I/O operation has 
stopped. The detail-writing loop neither checks cancellation/task identity nor 
coordinates with deletion.
   
      A task can therefore finish writing after cleanup has removed the 
metadata and files. This was reproduced with both backends.
   
   4. **An older overview can overwrite a newer result.**
   
      Overview aggregation and publication have no serialization or version 
check.
   
      An aggregation can read the old job list, pause, and publish after 
another thread has deleted a job and published the updated list. The deleted 
job then reappears in the overview.
   
      This was reproduced with both backends.
   
   5. **Failed detail writes are reported as successfully loaded.**
   
      Detail-write IOExceptions are logged, but processing continues and 
eventually sets the archive state to CREATED.
   
      A transient write failure can therefore leave a detail resource 
permanently missing while subsequent scans skip the cached archive instead of 
retrying.
   
      This was reproduced with both backends.
   
   6. **FILE storage exposes missing-file and partial-content read windows.**
   
      File replacement uses `deleteIfExists()` followed by `Files.write()` 
directly to the target path.
   
      Concurrent readers can observe a missing file or incomplete JSON. This 
finding follows from code inspection; partial JSON was not reproduced in this 
validation.
   
      ROCKSDB atomic single-key writes avoid this particular problem, but do 
not prevent the higher-level consistency races above.
   
   7. **Shutdown can leave requests waiting indefinitely.**
   
      No definite circular lock deadlock was identified. However, registry 
shutdown does not cancel queued Futures discarded by `shutdownNow()`.
   
      Validation confirmed that an executor can terminate while a discarded 
Future remains incomplete. A request blocked in `Future.get()` can then wait 
indefinitely.
   
   The scan caches also use ordinary HashMap/HashSet instances without 
coordinating background scans and HTTP-triggered scans, leaving additional 
thread-safety gaps.
   
   


-- 
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]

Reply via email to