cds-dbs icon indicating copy to clipboard operation
cds-dbs copied to clipboard

postgres in hybrid profile

Open lucasborin opened this issue 2 years ago • 4 comments

Description of erroneous behaviour

The statement cds watch --profile hybrid binds the Postgres instance, but the CAP read fails due to resource timeout.

CAP database call:

const entries = await cds.db.run(`SELECT * FROM ... LIMIT 10`)

Console (sensitive data hidden):

[odata] - POST /odata/v4/...
[cds] - TimeoutError: ResourceRequest timed out
    at ResourceRequest._fireTimeout (/home/.../node_modules/generic-pool/lib/ResourceRequest.js:62:17)
    at Timeout.bound (/home/.../node_modules/generic-pool/lib/ResourceRequest.js:8:15)
    at listOnTimeout (node:internal/timers:569:17)
    at process.processTimers (node:internal/timers:512:7)

Project .cdsrc.json:

{
    "requires": {
        "destinations": true,
        "db": {
            "kind": "postgres",
            "dialect": "postgres",
            "impl": "@cap-js/postgres"
        },
        "auth": {
            "kind": "xsuaa",
            "restrict_all_services": false
        }
}

Project .cdsrc-private.json (sensitive data hidden):

{
  "requires": {
    "[hybrid]": {
      "destinations": {
        "binding": {
          "type": "cf",
          "apiEndpoint": "...",
          "org": "...",
          "space": "...",
          "instance": "...",
          "key": "...",
          "resolved": false
        },
        "kind": "destinations",
        "vcap": {
          "name": "destinations"
        }
      },
      "db": {
        "binding": {
          "type": "cf",
          "apiEndpoint": "...",
          "org": "...",
          "space": "...",
          "instance": "...",
          "key": "...",
          "resolved": false
        },
        "kind": "postgres",
        "vcap": {
          "name": "db"
        }
      },
      "auth": {
        "binding": {
          "type": "cf",
          "apiEndpoint": "...",
          "org": "...",
          "space": "...",
          "instance": "...",
          "key": "...",
          "resolved": false
        },
        "kind": "xsuaa",
        "vcap": {
          "name": "auth"
        }
      }
    }
  }
}

Details about your project

Interal Ask i840577
Node.js v18.19.0
@sap/cds 7.3.1
@sap/cds-compiler 4.3.2
@sap/cds-dk 7.3.2
@sap/cds-dk (global) 7.6.1
@sap/eslint-plugin-cds 2.6.3
@sap/cds-mtxs 1.12.1
@cap-js/cds-types 0.2.0

lucasborin avatar Feb 23 '24 20:02 lucasborin

hm, I did the same thing, but on Azure: https://github.com/Azure-Samples/app-service-javascript-sap-cap-quickstart/blob/293b5a4d78c3ccd2ca38440b0b01a19c2ae6f517/src/.cdsrc.json#L26 that worked ootb. → assumption: this might be an issue with CF/destination?

vobu avatar Feb 27 '24 15:02 vobu

@lucasborin have you been able to solve this problem on your end?

patricebender avatar Apr 29 '24 12:04 patricebender

@lucasborin have you been able to solve this problem on your end?

I'm using SAP HANA now, and I was not able to use the postgres in hybrid mode.

lucasborin avatar Apr 29 '24 19:04 lucasborin

[odata] - > READ Activities { '$count': 'true', '$filter': '(IsActiveEntity eq false or SiblingEntity/IsActiveEntity eq null)', '$select': 'HasActiveEntity,IsActiveEntity,accountManagerId,accountManagerName,activityAdministrator,activityDesc,activityId,activityOrg,contract,goLiveDate,modifiedAt,modifiedBy,projectManagerId,projectManagerName', '$skip': '0', '$top': '30' } [cds] - TimeoutError: ResourceRequest timed out at ResourceRequest._fireTimeout (/home/user/projects/timesheet/packages/server/node_modules/generic-pool/lib/ResourceRequest.js:62:17) at Timeout.bound (/home/user/projects/timesheet/packages/server/node_modules/generic-pool/lib/ResourceRequest.js:8:15) at listOnTimeout (node:internal/timers:573:17) at process.processTimers (node:internal/timers:514:7) Active connections:0 { id: '1017596', level: 'ERROR', timestamp: 1720285318950 }

I am facing the same issue. Is there a solution or workaround available for this to test the postgre db in hybrid mode

arunkrishnamoorthy avatar Jul 06 '24 17:07 arunkrishnamoorthy

@arunkrishnamoorthy it is not possible to give support with the ResourceRequest timed out error. If you are still facing this issue please catch the error thrown here. Most likely the error message will already give you an indication of what is going wrong. Most likely the connection is being rejected as your host is blocked. It is standard practice for internal services to only allow known internal host to connect to the server.

BobdenOs avatar Oct 23 '24 11:10 BobdenOs

@BobdenOs I am facing the same error when running locally. Have similar configuration. The caught error is:

[server.js] - deploying... Error: getaddrinfo ENOTFOUND c-auto-ls-postgres-db.redacted.postgres.cosmos.azure.com at GetAddrInfoReqWrap.onlookupall [as oncomplete] (node:dns:118:26) at GetAddrInfoReqWrap.callbackTrampoline (node:internal/async_hooks:130:17) { errno: -3008, code: 'ENOTFOUND', syscall: 'getaddrinfo', hostname: 'c-auto-ls-postgres-db.redacted.postgres.cosmos.azure.com' }

[cds] - ❗️Uncaught Error: Connection terminated unexpectedly at C:\_space\AutoLS\apps\backend\node_modules\pg\lib\client.js:535:17 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async Object.all (C:\_space\AutoLS\apps\backend\node_modules\@cap-js\postgres\lib\PostgresService.js:179:26) at async PostgresService._checkCollation (C:\_space\AutoLS\apps\backend\node_modules\@cap-js\postgres\lib\PostgresService.js:102:21) at async Promise.all (index 2) at async PostgresService.begin (C:\_space\AutoLS\apps\backend\node_modules\@cap-js\db-service\lib\common\DatabaseService.js:70:7) at async PostgresService._begin [as dispatch] (C:\_space\AutoLS\apps\backend\node_modules\@sap\cds\lib\srv\srv-tx.js:200:3) at async get_prior_model (C:\_space\AutoLS\apps\backend\node_modules\@sap\cds\lib\dbs\cds-deploy.js:134:26) at async deploy.schema (C:\_space\AutoLS\apps\backend\node_modules\@sap\cds\lib\dbs\cds-deploy.js:74:37) at async C:\_space\AutoLS\apps\backend\node_modules\@sap\cds\lib\dbs\cds-deploy.js:39:19 { query: "SELECT collname FROM pg_collation WHERE collname = 'en-x-icu';\n ^"

dracovoldy avatar Nov 16 '24 13:11 dracovoldy

So it turns out this was something to do with enterprise VPN. I did not face this issue when running via vscode disconnected from the VPN.

dracovoldy avatar Nov 29 '24 23:11 dracovoldy