Skip to content

Conversation

@BobdenOs
Copy link
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
Collaborator

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

@BobdenOs
Copy link
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.

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.

2 participants