Dynamo Db LastEvaluatedKey Looping Issue

0

Hello Everyone,

I have a stepfuntion which invokes a lambda. The lambda queries the dynamo with GSI with limit 1 so it returns only 1 record while fetching and the last Evaluated key which we pass back to the step function.

Let’s say if we have 4 records with the required GSI, the lambda returns last evaluated key for 1st iteration as 2nd item and for 2nd it would be 3rd and so on…

But for last record where I expect there should be no last Evaluated key, it is returning first record as last Evaluated key and the loop continues until the GSI key value is changed.

  • Something in your logic is not as expected. Please share the code.

  • I am using PageIterable which executes the query and stores the result. And we get the Page Iterator using .iterator() method. we get the page using iterator.hasNext() and assigning page = iterator.next(). then we check if if the page has lastEvalualtedKey, if yes we add it the the last evaluated key.

  • Thanks for explaining, but its best to share the code, I can help you then.

  • Thanks Leeroy, Found the issue, commenting the answer

1개 답변
0
수락된 답변

I was updating the the GSIs after fetching the entity, hence the iterator considers that as an new entry in its list. Hence the loop was created. The fix was not to update the GSI or PK when it is paginated to maintain the entities' version

profile picture
AGS
답변함 7달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠