{"record":{"id":"4f90d975d62b2abe","repo":"egametang/ET","slug":"err-servicediscoverymasterunavailable","errorCode":"ERR_ServiceDiscoveryMasterUnavailable","errorMessage":"service discovery agent not ready, request: {requestName}, scene: {self.Root().Name}","messagePattern":"service discovery agent not ready, request: (.+?), scene: (.+?)","errorType":"exception","errorClass":"RpcException","httpStatus":null,"severity":"error","filePath":"Packages/cn.etetet.servicediscovery/Scripts/Hotfix/Server/ServiceDiscoveryAgentSystem.cs","lineNumber":452,"sourceCode":"                if (self.IsReady())\n                {\n                    return;\n                }\n\n                if (retry + 1 < totalRetryCount)\n                {\n                    int delay = GetMasterResolveRetryDelay(retry);\n                    await self.Root().TimerComponent.WaitAsync(delay);\n                }\n            }\n\n            self = selfRef;\n            if (self == null)\n            {\n                throw new Exception(\"service discovery agent disposed\");\n            }\n\n            throw new RpcException(ErrorCode.ERR_ServiceDiscoveryMasterUnavailable,\n                $\"service discovery agent not ready, request: {requestName}, scene: {self.Root().Name}\");\n        }\n\n        private static async ETTask TryLoadActiveMasterFromDbAsync(this ServiceDiscoveryAgent self)\n        {\n            if (self == null)\n            {\n                return;\n            }\n\n            EntityRef<ServiceDiscoveryAgent> selfRef = self;\n            Scene root = self.Root();\n            string rootName = root.Name;\n            DBManagerComponent dbManagerComponent = root.GetComponent<DBManagerComponent>();\n            if (dbManagerComponent == null)\n            {\n                return;\n            }","sourceCodeStart":434,"sourceCodeEnd":470,"githubUrl":"https://github.com/egametang/ET/blob/5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f/Packages/cn.etetet.servicediscovery/Scripts/Hotfix/Server/ServiceDiscoveryAgentSystem.cs#L434-L470","documentation":"RpcException with code ERR_ServiceDiscoveryMasterUnavailable, thrown at line 452 after EnsureReadyForRequestAsync exhausted all 30 resolve retries while the agent was still alive. It means the agent could not discover/register with any service-discovery master within MasterResolveMaxRetryCountWhenEndpointUnavailable iterations, so the request cannot be forwarded. This is the canonical 'master unreachable' failure surfaced to callers.","triggerScenarios":"ForwardToDiscoveryByFailover is called but the master endpoint is not bootstrapped (ServiceDiscoveryBootstrapSingleton.MasterActorId is default), the master scene is down, the master lease expired, or every register attempt failed. The loop calls TriggerBackgroundRegister and waits, but IsReady() (ServiceDiscoveryActorId set AND AgentRegistered status) never becomes true.","commonSituations":"Master scene not started or wrong scene-type configured; network partition between agent fiber and master fiber; master crashed and lease not renewed / not re-elected; DB unavailable so TryLoadActiveMasterFromDbAsync cannot recover the master record; startup ordering where dependent scenes start before the discovery master.","solutions":["Confirm the service-discovery master scene is running and its ActorId is published in ServiceDiscoveryBootstrapSingleton.","Check master election/lease health and that the master's heartbeat renews the lease before expiry.","Verify network connectivity and ActorMessage routing between the agent fiber and master fiber.","If using DB-backed master recovery, ensure the DB is reachable and the master record collection is correct.","Fix startup ordering so the master is elected before scenes issue discovery requests."],"exampleFix":"// before\nvar resp = await agent.ForwardToDiscoveryByFailover<T>(req, name);\n\n// after\nif (!agent.IsReady())\n{\n    Log.Warning($\"discovery not ready, queuing/skipping {name}\");\n    return default; // or retry at a higher level\n}\nvar resp = await agent.ForwardToDiscoveryByFailover<T>(req, name);","handlingStrategy":"retry","validationCode":"public static bool IsDiscoveryReady(ServiceDiscoveryAgent agent)\n{\n    return agent != null && agent.IsReady();\n}\n\nif (!IsDiscoveryReady(agent))\n{\n    // master not up; do not attempt forwarding yet\n}","typeGuard":null,"tryCatchPattern":"catch (RpcException e) when (e.Error == ErrorCode.ERR_ServiceDiscoveryMasterUnavailable)\n{\n    // master unreachable after retries; degrade gracefully / queue / alert\n    Log.Error($\"discovery master unavailable: {e.Message}\");\n}","preventionTips":["Start the discovery master scene before scenes that depend on it.","Monitor master lease renewal and failover.","Keep the DB available for master-record recovery."],"tags":["csharp","et-framework","service-discovery","rpc","master-election","network","configuration"],"backgroundTag":null,"analyzedSha":"5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f","analyzedAt":"2026-08-13T21:10:40.377Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}