{"record":{"id":"4216dc53f00368d5","repo":"TencentCloud/TencentDB-Agent-Memory","slug":"user-limit-exceeded","errorCode":"user_limit_exceeded","errorMessage":"user limit ${limit} reached for instance ${this.instanceId} (current: ${count})","messagePattern":"user limit (.+?) reached for instance (.+?) \\(current: (.+?)\\)","errorType":"error_code","errorClass":"MetadataError","httpStatus":null,"severity":"error","filePath":"MemoryCore/src/metadata/service/metadata-service.ts","lineNumber":355,"sourceCode":"\n  /** 校验用户存在，否则抛 not_found。 */\n  private async requireUser(userId: string): Promise<UserEntity> {\n    const user = await this.getUserById(userId);\n    if (!user) throw new MetadataError(\"user_not_found\", `user not found: ${userId}`);\n    return user;\n  }\n\n  get rawStore(): IMetadataStore {\n    return this.store;\n  }\n\n  private async assertUserQuota(): Promise<void> {\n    const count = await this.store.countUsers();\n    const limit = this._configParams\n      ? await this._configParams.getEffectiveInt(\"quota\", \"max_users_per_instance\")\n      : this.quota.maxUsersPerInstance;\n    if (count >= limit) {\n      throw new MetadataError(\n        \"user_limit_exceeded\",\n        `user limit ${limit} reached for instance ${this.instanceId} (current: ${count})`,\n      );\n    }\n  }\n\n  private async assertTeamQuota(): Promise<void> {\n    const count = await this.store.countTeams();\n    const limit = this._configParams\n      ? await this._configParams.getEffectiveInt(\"quota\", \"max_teams_per_instance\")\n      : this.quota.maxTeamsPerInstance;\n    if (count >= limit) {\n      throw new MetadataError(\n        \"team_limit_exceeded\",\n        `team limit ${limit} reached for instance ${this.instanceId} (current: ${count})`,\n      );\n    }\n  }","sourceCodeStart":337,"sourceCodeEnd":373,"githubUrl":"https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/3efcd317b84146d6a08518ac0f7ee7c8a8d200ec/MemoryCore/src/metadata/service/metadata-service.ts#L337-L373","documentation":"MetadataError code 'user_limit_exceeded' is thrown by assertUserQuota when the number of users in a metadata instance has reached the configured maximum. The limit is read from ConfigParams ('quota'/'max_users_per_instance') or falls back to this.quota.maxUsersPerInstance. It is a guard so one instance cannot accumulate unbounded users.","triggerScenarios":"Calling createUserWithType (directly or via createUser / createNormalUser / createNormalUserWithKey / initAdminUser) when store.countUsers() >= limit.","commonSituations":"Deployments that grew past the license/configured quota; quota.maxUsersPerInstance left at a small default while many test users were created; effective config in ConfigParams overriding the code-level quota unexpectedly.","solutions":["Delete unused users via deleteUsers to free quota slots","Raise the quota: set quota.max_users_per_instance in ConfigParams or increase quota.maxUsersPerInstance in the service config","Read the 'current' and 'limit' values from the error message to confirm headroom before bulk-importing users"],"exampleFix":"// before\nconst svc = new MetadataService({ quota: { maxUsersPerInstance: 10 } });\nawait svc.createNormalUser({ username: 'user11' }); // throws user_limit_exceeded\n// after\nconst svc = new MetadataService({ quota: { maxUsersPerInstance: 100 } });\nawait svc.createNormalUser({ username: 'user11' }); // ok","handlingStrategy":"try-catch","validationCode":"const count = await store.countUsers();\nconst limit = configParams\n  ? await configParams.getEffectiveInt('quota', 'max_users_per_instance')\n  : quota.maxUsersPerInstance;\nif (count >= limit) throw new Error(`user quota full (${count}/${limit})`);","typeGuard":null,"tryCatchPattern":"try {\n  await svc.createNormalUser(input);\n} catch (e) {\n  if (e instanceof MetadataError && e.code === 'user_limit_exceeded') {\n    // surface quota info / back off\n  } else throw e;\n}","preventionTips":["Check user count against the configured limit before bulk imports","Keep quota.maxUsersPerInstance in sync with deployment needs","Monitor user growth and alert before hitting the quota"],"tags":["quota","users","limit-exceeded"],"backgroundTag":"quota-limit-exceeded","analyzedSha":"3efcd317b84146d6a08518ac0f7ee7c8a8d200ec","analyzedAt":"2026-09-01T05:44:22.276Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}