Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SAP HANA: hdb-pool is deprecated - should use standard connection pooling #9890

Open
1 of 18 tasks
SchroederSteffen opened this issue Mar 27, 2023 · 5 comments · May be fixed by #10786
Open
1 of 18 tasks

SAP HANA: hdb-pool is deprecated - should use standard connection pooling #9890

SchroederSteffen opened this issue Mar 27, 2023 · 5 comments · May be fixed by #10786

Comments

@SchroederSteffen
Copy link

SchroederSteffen commented Mar 27, 2023

Feature Description

The package hdb-pool for the SAP HANA driver has been archived & deprecated: ckyycc/hdb-pool@256c645

This is because the standard @sap/hana-client supports connection pooling out-of-the-box by now: https://help.sap.com/docs/SAP_HANA_CLIENT/f1b440ded6144a54ada97ff95dac7adf/e252ff9b2cb44dd9925901e39025ce77.html

It would make sense to replace the usage of hdb-pool with the default pooling.
Looking at the documentation, TypeORM could probably use at least the 'implicit' without too much effort?

The Solution

Use standard connection pooling of @sap/hana-client.

Considered Alternatives

n/a

Additional Context

I didn't look into the code yet, but may be able to do so later. I'm opening this issue already for tracking purposes.

Relevant Database Driver(s)

  • aurora-mysql
  • aurora-postgres
  • better-sqlite3
  • cockroachdb
  • cordova
  • expo
  • mongodb
  • mysql
  • nativescript
  • oracle
  • postgres
  • react-native
  • sap
  • spanner
  • sqlite
  • sqlite-abstract
  • sqljs
  • sqlserver

Are you willing to resolve this issue by submitting a Pull Request?

Yes, I have the time, but I don't know how to start. I would need guidance.

@SvendDomdey
Copy link

SvendDomdey commented Sep 26, 2023

Hi,

just wanted to ask if you had the chance to consider Steffen's feature request in the mean time.

Thanks you very much
Svend

@alumni
Copy link
Contributor

alumni commented Nov 2, 2023

I am not sure if explicit connection pooling should be used, implicit should be enough.

Replacing hdb-pool with @sap/hana-client should be quite straight-forward otherwise:

  1. driver/sap/SapDriver.ts: SapDriver would need to use the methods from @sap/hana-client for connecting/disconnecting, tracing (events), etc. -> check this.driver and this.master.
  2. driver/sap/SapDriver.ts: SapDriver.loadDependencies should only load @sap/hana-client.
  3. driver/sap/SapConnectionOptions.ts: keep driver and remove hanaClientDriver. pool and poolSize will also need to be removed/changed (pool contains hdb-pool settings) - new options depending on the pooling strategy might need to be added (e.g. { pooling: boolean, maxPoolSize: number, poolingCheck: boolean, connectionLifetime: number, communicationTimeout: number }) - it's true that the users could also pass them to the driver via BaseDataSourceOptions.extra, but that's deprecated.
  4. platform/PlatformTools.ts: remove hdb-pool.

Connection pooling is only supported in @sap/hana-client (NAPI), node-hdb (pure JS) does not support it. However, even though the two drivers should in theory be compatible with each other (except for pooling and a few other things), somehow node-hdb did not work for me correctly out-of-the-box (I actually had to patch both typeorm and node-hdb to get it working). So I doubt there is anyone using the alternative client. Worst case, if implicit pooling is used, the driver will ignore the options and a single connection will exist.

@SvendDomdey
Copy link

Hi,

thank you for your comment. I had a look into it last year but got stuck in the "otherwise" path pretty quickly. That's why I also forgot to update here, sorry.

Currently it doesn't seem like we would be able to do this.

@alumni
Copy link
Contributor

alumni commented Jan 19, 2024

I haven't used pooling directly from hana-client yet, and SAP documentation is as it always is, but looking into the source code of CAP/CDS can be a good inspiration (if you can understand their architecture).

Currently, hbd-pool is still working for me (heavily patched to support multi-tenant logging though), and since this is probably about a week of work, if I ever look into it, it might not be very soon.

Even if I will implement this, I need to test it in a multi-tenant environment for a while to see that things are still fine :)

@SvendDomdey
Copy link

I was able to use some time to look further into this. Somehow following your instructions (mostly - did not know what to do with the driver object) at least the connection with implicit pooling according to config was working 😄 - I was able to get back some data from a sample HANA I was using.

I put the POC coding at https://github.com/SvendDomdey/typeorm/tree/poc-wo-hdb-pool. But I did only changes at few points and do not really oversee the consistency of the classes/properties here. Also as you also mentioned, thorough testing will be required (there may be many different use cases).

@viniscoelho viniscoelho linked a pull request Mar 21, 2024 that will close this issue
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants