|
82 | 82 | _safeErrorCode, |
83 | 83 | _strictJson, |
84 | 84 | ) |
85 | | -from dartlab.dataHub.isolation.processLifecycle import becomeProcessGroupLeader |
| 85 | +from dartlab.dataHub.isolation.processLifecycle import ( |
| 86 | + becomeProcessGroupLeader, |
| 87 | + describeStalledThread, |
| 88 | +) |
86 | 89 | from dartlab.dataHub.paging.runtime import ( |
87 | 90 | MAX_OWNER_PROCESS_REQUEST_BYTES, |
88 | 91 | requireDeadline, |
@@ -748,28 +751,37 @@ def runWorker() -> None: |
748 | 751 | joinSeconds = max(0.0, workDeadline - time.perf_counter()) |
749 | 752 | worker.join(timeout=joinSeconds) |
750 | 753 | if worker.is_alive(): |
| 754 | + # 멈춘 지점을 자식 stderr 로 남긴다. 부모가 받는 것은 평평한 실패 코드라 |
| 755 | + # 여기서 잡지 않으면 어디서 섰는지 영영 알 수 없다. |
| 756 | + print( |
| 757 | + f"[dataHub] eager worker stalled at {describeStalledThread(worker.ident)}", |
| 758 | + file=sys.stderr, |
| 759 | + flush=True, |
| 760 | + ) |
751 | 761 | raise RuntimeError("EAGER_PROCESS_WORKER_DID_NOT_FINISH") |
752 | 762 | if len(output) != 1: |
753 | 763 | raise RuntimeError("EAGER_PROCESS_WORKER_RESULT_INVALID") |
754 | 764 | sendConnection.send_bytes(_strictJson(output[0])) |
755 | 765 | except BaseException as error: |
756 | | - if worker is None or not worker.is_alive(): |
757 | | - try: |
758 | | - sendConnection.send_bytes( |
759 | | - _strictJson( |
760 | | - { |
761 | | - "artifactId": artifactId, |
762 | | - "byteCount": None, |
763 | | - "digest": None, |
764 | | - "errorCode": _safeErrorCode(error), |
765 | | - "kind": "result", |
766 | | - "rowCount": None, |
767 | | - "status": "failed", |
768 | | - } |
769 | | - ) |
| 766 | + # worker 는 결과를 `output` 리스트에만 넣고 이 connection 을 만지지 않는다. |
| 767 | + # 그래서 worker 가 아직 살아 있어도 여기서 실패를 보내는 것이 안전하다. |
| 768 | + # 보내지 않으면 부모는 원인 대신 자기 기한이 다 찰 때까지 침묵을 받는다. |
| 769 | + try: |
| 770 | + sendConnection.send_bytes( |
| 771 | + _strictJson( |
| 772 | + { |
| 773 | + "artifactId": artifactId, |
| 774 | + "byteCount": None, |
| 775 | + "digest": None, |
| 776 | + "errorCode": _safeErrorCode(error), |
| 777 | + "kind": "result", |
| 778 | + "rowCount": None, |
| 779 | + "status": "failed", |
| 780 | + } |
770 | 781 | ) |
771 | | - except BaseException: |
772 | | - pass |
| 782 | + ) |
| 783 | + except BaseException: |
| 784 | + pass |
773 | 785 | finally: |
774 | 786 | workerGate.set() |
775 | 787 | sendConnection.close() |
|
0 commit comments