Skip to content

fix: keep space for potential client info update segments. - #293

Closed
BobdenOs wants to merge 1 commit into
SAP:masterfrom
BobdenOs:fix/update-client-info
Closed

fix: keep space for potential client info update segments.#293
BobdenOs wants to merge 1 commit into
SAP:masterfrom
BobdenOs:fix/update-client-info

Conversation

@BobdenOs

Copy link
Copy Markdown
Contributor

As part of @cap-js/hana for @sap/cds while implementing prepare statement re-use. Seemingly random stmt.exec calls started failing with the error Packet size limit exceeded.

After further investigations the following reproduction script showed the root cause:

const prepare = await tx.dbc._prepare(`WITH A AS (SELECT ? AS JSON FROM DUMMY UNION ALL SELECT TO_BLOB(NULL) AS JSON FROM DUMMY) SELECT * FROM DUMMY`)

const gen = async function* () {
  for (let i = 0; i < 64; i++) yield Buffer.allocUnsafe(1024)
}
tx.dbc.set({'size': '64'}) // connection.getClientInfo().setProperty('size','64')
const res = await new Promise((resolve, reject) => {
  prepare.exec([Readable.from(gen(), { objectMode: false })], (err, res) => { if (err) { reject(err) } else { resolve(res) } })
})

When only using hdb it should look something like:

const gen = async function* () {
  for (let i = 0; i < 64; i++) yield Buffer.allocUnsafe(1024)
}

connection.prepare(`WITH A AS (SELECT ? AS JSON FROM DUMMY UNION ALL SELECT TO_BLOB(NULL) AS JSON FROM DUMMY) SELECT * FROM DUMMY`, (err, stmt) => {
  connection.getClientInfo().setProperty('size', '64') // <== additional information not counted for total packet size
  stmt.exec([Readable.from(gen(), { objectMode: false })],(err, res) => {
    if(err) process.exit(1)
    process.exit(0)
  })
})

Currently uploading LOB parameters works with hdb only when another operation has happened between getClientInfo().setProperty(...) and stmt.exec. Which usually is fulfilled by calling prepare before stmt.exec.

@davidbrandow

Copy link
Copy Markdown
Contributor

To confirm, was this with 2.26.4 or later, or with an earlier version?

@BobdenOs

Copy link
Copy Markdown
Contributor Author

@davidbrandow this issue was reproduced with hdb@0.19.12 and hdb@2.27.1. The function getAvailableSize seems to have never considered the client info being pre pended to the message.

@linjun-he-sap

Copy link
Copy Markdown
Contributor

Hi @BobdenOs, thanks for your PR!
You change has been consumed in our internal repo, and merged with modifications and tests.
This change (23aa0e6) has been merged into this external repo by merge commit f26df55, and has been included in the patch release v2.29.6 (https://www.npmjs.com/package/hdb/v/2.29.6)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants