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

What is the proper way to pass array as a parameter to UDF? #275

Closed
qw4n7y opened this issue Dec 18, 2019 · 6 comments
Closed

What is the proper way to pass array as a parameter to UDF? #275

qw4n7y opened this issue Dec 18, 2019 · 6 comments

Comments

@qw4n7y
Copy link

qw4n7y commented Dec 18, 2019

Good day! I have confusions about the right way to pass array to UDF. I've not found any info about that in docs.
Goal: pass array of integers to filter records. So i've wrote UDF with filter / map pipeline and made calls with QueryAggregate
My first approach: pass slice wrapped with aerospike.NewValueArray / aerospike.NewListValue. That worked and in UDF i've got this argument seeing as userdata. But! after that memory leak had always occur:
Screen Shot 2019-12-18 at 12 09 20
Screen Shot 2019-12-18 at 12 10 00
After all i've come with solution to pass array as a string (what a shame on me) and use loadstring("return "..str)() to parse the string into lua's table object.
What is the proper way for doing that? Thanks in advance

@khaf
Copy link
Collaborator

khaf commented Dec 18, 2019

What do you mean by Memory leak? Does the memory utilization of your process (resident memory) increase over time? Memory utilization is different from memory leak.
Keep in mind that QueryAggregate fetches a lot of records back from the server and processes the final reduction on the client side. That would potentially use a lot of memory.

For filtering records on the server side, you could potentially use Predicates

@qw4n7y
Copy link
Author

qw4n7y commented Dec 18, 2019

By memory leak i meant explosive memory allocation which exceeded 1gb per go-routine constraint. Predicates are not the case since i can not filter records which has bins with value included in my set, only exact value or number range. There were only 3 records in my dev environment so there could not be many data there.
I came to the understanding that the most proper way is to keep all the data in the key, generate the keys of records of interest and make client.BatchGet(policy, keys).

@khaf
Copy link
Collaborator

khaf commented Dec 19, 2019

I don't know how much data you may have, but all that data is serialized for a lua engine to process for the final reduction. That lua engine MAY also not free that data fast enough.
If you could provide a gist, I may be able to help.

@khaf
Copy link
Collaborator

khaf commented Dec 23, 2019

Did you make any progress?

@qw4n7y
Copy link
Author

qw4n7y commented Dec 23, 2019

https://github.com/qw4n7y/golang-aerospike-client-issue-reproduction. Please have a look at code which reproduces my issue

@khaf
Copy link
Collaborator

khaf commented Dec 23, 2019

Good news! This issue was related to #272, which is fixed in the latest release (v2.7.0)

@khaf khaf closed this as completed Dec 23, 2019
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

No branches or pull requests

2 participants