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

[defect] insert lob with size more or equal to 8192 will fail #113

Closed
haiquanli-sap opened this issue Mar 24, 2023 · 1 comment
Closed
Labels

Comments

@haiquanli-sap
Copy link

I think this is a bug in current version of github.com/SAP/go-hdb v1.1.5
It works with 1.1.3 but not 1.1.5.

I made an experiment that when we insert a lob data that length >= 8192, it will fail with message :"Repository Error: Executing Statement List, protocol error: invalid number of lob parameter ids 1"

The callstack is:
github.com/SAP/go-hdb/driver.(*conn).encodeLobs(0xc000478230, 0x0, {0xc0006d6f48, 0x1, 0x1}, {0xc0007a8000, 0x1c, 0x0?}, {0xc00007c000, 0x1c, ...})
/go/src/github.wdf.sap.corp/bdh/rms/vendor/github.com/SAP/go-hdb/driver/connection.go:1716 +0x43a
github.com/SAP/go-hdb/driver.(*conn)._execBatch(0xc000478230, 0xc0006edd00, {0xc00007c000, 0x1c, 0x1c}, 0x1c?, 0x0)
/go/src/github.wdf.sap.corp/bdh/rms/vendor/github.com/SAP/go-hdb/driver/connection.go:1346 +0x52f
github.com/SAP/go-hdb/driver.(*conn)._exec(0xc000478230, 0xc0006edd00, {0xc00007c000?, 0x1c, 0x1c}, 0x0?, 0x1586500?)
/go/src/github.wdf.sap.corp/bdh/rms/vendor/github.com/SAP/go-hdb/driver/connection.go:1297 +0x319
github.com/SAP/go-hdb/driver.(*stmt).exec(0xc00064e900, {0xc00007c000, 0x1c, 0x1c})
/go/src/github.wdf.sap.corp/bdh/rms/vendor/github.com/SAP/go-hdb/driver/connection.go:748 +0x43c
github.com/SAP/go-hdb/driver.(*stmt).ExecContext.func1()
/go/src/github.wdf.sap.corp/bdh/rms/vendor/github.com/SAP/go-hdb/driver/connection.go:703 +0x206
created by github.com/SAP/go-hdb/driver.(*stmt).ExecContext
/go/src/github.wdf.sap.corp/bdh/rms/vendor/github.com/SAP/go-hdb/driver/connection.go:699 +0x53a

Our developer debugged the code and found that:

I went through the code and they have a bug. LOBs that are < 8192 are sent in-line it looks like, only when you reach size 8192 does it generate a locator ID. At that point, it goes into a loop of all fields and if that field is a LOB, it expects it to have an ID, but we have 6 LOBs (1 size 8192, 5 size < 8192). So there is only 1 locator ID and when it gets to that next LOB field, it throws that error because it expects an ID to be present.

In 1.1.3 the code returned 6 locator IDs. So looks like they added logic to allow smaller lobs not to return locator IDs but forgot to fix the loop that looks for them.

File a bug with them and don't upgrade to 1.1.5 until it is fixed.

The issue is in connection.go:

func (c *conn) encodeLobs(cr *callResult, ids []p.LocatorID, inPrmFields []*p.ParameterField, nvargs []driver.NamedValue) error {
in this for loop:

for i, f := range inPrmFields {

If it makes it in there, it expects every Lob field to have a locator ID.

It seems to be an issue from perf changes in 1.1.4 31ceb2e#diff-5265516ccba5c11855cd41ea179d0bb050bab7d61b0b57509e180bf846edf13b

@stfnmllr
Copy link
Contributor

Thanks for raising! Was able to reproduce the issue but v1.1.3 is affected as well. Anyway,
https://github.com/SAP/go-hdb/releases/tag/v1.1.6
should fix it.

@stfnmllr stfnmllr added the bug label Mar 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants