AWS Lambda showing previous output with current output

Eshan Bhagat :

So as I have described, my AWS Lambda function is showing the output for my previous input, along with my present input's output. My lambda function takes IT keywords as JSONArray input and fetches certain records from the mySQL table where the keyword exists in the column. For eg.

I run the function with this input :-

input: { "keywords": ["Python"] } output: { "records": [{"record 1": "Python 1", "record 2": "Python 2"}] }

But when I run the same function on another keyword, say, HTML :-

input: { "keywords": ["HTML"] } output: { "records": [{"record 1": "HTML 1", "record 2": "HTML 2"}, {"record 1": "Python 1", "record 2": "Python 2"}] }

The current output retains the previous output. I have checked my code, and it runs properly on Eclipse. Is there a configuration issue with the AWS Lambda where it retains previous input?

Marcin :

Lambda can reuse your execution context. So I think this is what you are observing. Maybe you store your data in some global dict or list and when it is reused its being updated.

More on the execution context reuse is here: https://aws.amazon.com/blogs/compute/container-reuse-in-lambda/

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=11134&siteId=1