Skip to content

The readiness probe still loads every escrow row, and #502 was closed without the change landing #563

Description

@Omoboi-dev

Category: Performance
Difficulty: Medium

Description

checkDatabase() in app.controller.ts:

private async checkDatabase(): Promise<ComponentHealth> {
  try {
    await this.prismaService.escrow.findMany({});
    return { status: 'ok' };
  } catch (err) {

findMany({}) with no where, no take and no select returns every escrow row. This runs on GET /health/ready and on the legacy GET /health, both of which a load balancer polls on a short interval.

#502 was filed for exactly this and is now closed, but the code on ac3b115 is unchanged. No merged pull request references it. Worth checking the others closed in the same batch before trusting their state.

Today the store is in memory so the cost is a full Map copy per probe. Once #475 lands and this is a real PrismaClient, it becomes an unbounded SELECT * against the escrow table on every health check.

Location

  • src/app.controller.ts
  • src/prisma/prisma.service.ts

Example commits

perf(health): probe the database with a bounded query

Acceptance Criteria

  • The database probe does not load table contents. A SELECT 1, a count with a limit, or a findFirst with select: { id: true } are all acceptable.
  • The probe still reports down when the database is unreachable.
  • The response shape of /health/ready is unchanged.
  • Tests are required. Assert the probe reports down on a thrown error and ok otherwise, and that it does not call findMany.

Technical Notes

findFirst({ select: { id: true } }) is the smallest change that keeps working through the in-memory store and a real client. A raw SELECT 1 is cheaper but will need the in-memory fake to support it.

Please reopen or reference #502 in the pull request so the closed-without-a-fix trail is visible.

Out of scope: the Horizon and Redis probes.


Before you start

  • Set up with the steps in CONTRIBUTING.md. Node 22 is required (.nvmrc), use npm ci rather than npm install, and export DATABASE_URL (or copy .env.example to .env) before npx prisma generateprisma.config.ts reads it at load.
  • Branch from dev and open your pull request against dev. main is the released baseline.
  • Tests needing an authenticated caller should use the bearer() helper in test/auth-helper.ts, which mints a genuinely signed SEP-10 token. Never send a raw Stellar address, and never a placeholder, as a bearer token.
  • You may cover more than one issue in a single pull request.

Join our community: https://t.me/+Y8K7AmrX9kViOTBk

Metadata

Metadata

Assignees

No one assigned

    Labels

    complexity: medium150 pts. New endpoint, service method, integration testperformanceperformance

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions