{"record":{"id":"1eda83b2c1620a46","repo":"TencentCloud/TencentDB-Agent-Memory","slug":"storage-unavailable-for-instance-instanceid","errorCode":null,"errorMessage":"Storage unavailable for instance ${instanceId}","messagePattern":"Storage unavailable for instance (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"MemoryCore/src/offload_server/offload-task-executor.ts","lineNumber":667,"sourceCode":"  /**\n   * Extract sessionId from task data or task.sessionId.\n   */\n  private extractSessionId(task: TaskPayload): string | undefined {\n    const data = task.data as Record<string, unknown> | undefined;\n    // Prefer explicit sessionId in data\n    if (data?.sessionId && typeof data.sessionId === \"string\") {\n      return data.sessionId;\n    }\n    // Fallback: task-level sessionId\n    if (task.sessionId) {\n      return task.sessionId;\n    }\n    return undefined;\n  }\n\n  private async resolveStorageOrThrow(instanceId: string): Promise<StorageAdapter> {\n    const storage = await this.deps.resolveStorage(instanceId);\n    if (!storage) throw new Error(`Storage unavailable for instance ${instanceId}`);\n    return storage;\n  }\n\n  private async readState(storage: StorageAdapter, basePath: string): Promise<OffloadState> {\n    const raw = await storage.readFile(`${basePath}/state.json`);\n    if (!raw) return defaultOffloadState();\n    try {\n      return { ...defaultOffloadState(), ...JSON.parse(raw) };\n    } catch {\n      return defaultOffloadState();\n    }\n  }\n\n  private async writeState(storage: StorageAdapter, basePath: string, state: OffloadState): Promise<void> {\n    await storage.writeFile(`${basePath}/state.json`, JSON.stringify(state));\n  }\n\n  private findBoundaryByTimestamp(","sourceCodeStart":649,"sourceCodeEnd":685,"githubUrl":"https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/3efcd317b84146d6a08518ac0f7ee7c8a8d200ec/MemoryCore/src/offload_server/offload-task-executor.ts#L649-L685","documentation":"OffloadTaskExecutor.resolveStorageOrThrow resolves a StorageAdapter for an offloaded session instance before reading/writing its state. If deps.resolveStorage returns undefined — meaning no storage backend is registered or reachable for that instanceId — the executor refuses to run the task because offload work is impossible without a store.","triggerScenarios":"Executing an offload task (state restore/persist) whose instanceId has no registered storage adapter, e.g. the instance was deregistered, the storage plugin failed to initialize, or the resolver map lost the entry after a restart.","commonSituations":"Storage service down or not configured when offload tasks replay from a queue; instance IDs carried over from a previous deployment whose storage bindings were not migrated; race between instance eviction and a queued offload task.","solutions":["Verify resolveStorage has an adapter registered for this instanceId (check the resolver/deps wiring)","Re-register or recreate the instance's storage binding before re-enqueueing the task","Check storage backend health/config (credentials, endpoint) that may cause resolveStorage to return undefined","Add a guard to skip/park tasks for unknown instances instead of retrying indefinitely"],"exampleFix":"// before\nconst storage = await executor.run(task); // throws if storage gone\n// after\nconst storage = await deps.resolveStorage(task.instanceId);\nif (!storage) { await queue.park(task, 'storage-unavailable'); return; }","handlingStrategy":"try-catch","validationCode":"const storage = await deps.resolveStorage(instanceId);\nif (!storage) { /* skip/park task */ }","typeGuard":null,"tryCatchPattern":"try { await executor.run(task); } catch (e) { if (String(e.message).startsWith('Storage unavailable')) { await queue.park(task, 'storage-unavailable'); } else throw e; }","preventionTips":["Health-check storage adapters before enqueueing offload tasks","Clean up queued tasks when an instance is deregistered","Alert on resolveStorage returning undefined instead of failing deep in task execution"],"tags":["storage","offload","instance-lifecycle"],"backgroundTag":"storage-unavailable","analyzedSha":"3efcd317b84146d6a08518ac0f7ee7c8a8d200ec","analyzedAt":"2026-09-01T05:44:22.276Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}