{"record":{"id":"99b636b96436e30e","repo":"apache/beam","slug":"the-requesting-owner-must-be-registered","errorCode":null,"errorMessage":"The requesting owner must be registered.","messagePattern":"The requesting owner must be registered\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/utils/subprocess_server.py","lineNumber":116,"sourceCode":"            owner)\n        return\n      del self._live_owners[owner]\n      for key, entry in list(self._cache.items()):\n        if owner in entry.owners:\n          entry.owners.remove(owner)\n        if not entry.owners:\n          to_delete.append(entry.obj)\n          del self._cache[key]\n    # Actually call the destructors outside of the lock.\n    for value in to_delete:\n      self._destructor(value)\n\n  def get(self, *key, owner=None):\n    with self._lock:\n      if not self._live_owners:\n        raise RuntimeError(\"At least one owner must be registered.\")\n      if owner is not None and owner not in self._live_owners:\n        raise RuntimeError(\"The requesting owner must be registered.\")\n\n      if key not in self._cache:\n        self._cache[key] = _SharedCacheEntry(self._constructor(*key), set())\n      if owner is not None:\n        self._cache[key].owners.add(owner)\n        for live_owner, is_context in self._live_owners.items():\n          if is_context:\n            self._cache[key].owners.add(live_owner)\n      else:\n        for live_owner in self._live_owners:\n          self._cache[key].owners.add(live_owner)\n      return self._cache[key].obj\n\n  def force_remove(self, *key):\n    with self._lock:\n      entry = self._cache.pop(key, None)\n    if entry is not None:\n      self._destructor(entry.obj)","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/utils/subprocess_server.py#L98-L134","documentation":"The _SharedCache.get() method refuses to return a cached resource (like a subprocess server handle) when the caller supplies an owner name that is not among the currently registered live owners. Owners are registered when they first use the cache and unregistered when they release the resource; this check prevents an unregistered (already released) owner from re-acquiring or keeping shared resources alive. It is a bookkeeping/state error, not a resource failure.","triggerScenarios":"Calling get(key..., owner=X) after X was removed from _live_owners (e.g. after a context manager exit or release), or passing an owner that was never registered, while at least one other owner is live.","commonSituations":"Reusing a cache/context-manager object after its 'with' block ended; nested pipelines sharing a subprocess server where one owner released it before another tries to access it; passing the wrong owner string/handle.","solutions":["Ensure the owner that calls get() is the same object that originally registered (typically the 'with' context owner).","Re-enter the owning context manager so the owner is re-registered before calling get().","Do not pass an owner at all if you only need to look up an existing cache entry.","Fix owner lifecycle ordering so all consumers release owners only after the last get()."],"exampleFix":"// before\nshared_cache.get(('jar',), owner=released_owner)\n// after\nwith shared_cache_entries(...) as owner:\n    shared_cache.get(('jar',), owner=owner)","handlingStrategy":"validation","validationCode":"def owner_is_registered(cache, owner):\n    return owner is None or owner in cache._live_owners\n# call get() only if owner_is_registered(cache, owner)","typeGuard":"def is_live_owner(cache, owner):\n    return owner is None or owner in cache._live_owners","tryCatchPattern":null,"preventionTips":["Keep a single owner identity per context and reuse it","Never call get() after the owning context exited","Omit owner for read-only lookups","Release owners only after all consumers finish"],"tags":["python","state","resource-lifecycle","apache-beam"],"backgroundTag":"invalid-state-transition","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}