aws-connected-device-framework icon indicating copy to clipboard operation
aws-connected-device-framework copied to clipboard

fix(assetlibrary): add retry mechanism for connection error

Open yuma124 opened this issue 8 months ago • 4 comments

Description

Since #168, we have occasionally encountered database connection errors. These errors are related to database connectivity, and in my opinion they should be retried in the AssetLibrary. In this Pull Request, I've added retry mechanism for connection errors.

Type of change

  • [x] Bug fix (non-breaking change which fixes an issue)
  • [ ] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • [x] Refactor (existing code being refactored)
  • [ ] This change includes a documentation update

Submission Checklist

  • [x] CI dry-run passing
  • [x] Integration tests passing locally
  • [x] Change logs generated
Additional Notes:

yuma124 avatar Oct 30 '23 07:10 yuma124

Thanks for the PR @yuma124 ! I'll aim to review it by end-of-week

canavandl avatar Nov 01 '23 14:11 canavandl

I feel like a more proper fix here would be to open the DB connection outside of the lambda handler (from here):

A common best practice is to open the database connection outside the Lambda handler function so that it can be reused with each handler call.

aaronatbissell avatar Jan 26 '24 13:01 aaronatbissell

I feel like a more proper fix here would be to open the DB connection outside of the lambda handler (from here):

A common best practice is to open the database connection outside the Lambda handler function so that it can be reused with each handler call.

+1 to this.

ts-amz avatar Jan 26 '24 17:01 ts-amz

@aaronatbissell @ts-amz Thank you for your suggestion. I understand the importance of reusing the DB connection with each handler call. I have structured the code in a way that allows the DB connection to be reused within the Lambda's execution context.

Is it necessary to open the DB connection outside of the Lambda handler? If we refer to the Neptune sample code here, we can see that they also open the DB connection in the lambda handler and reuse with each handler call.

If there are any specific concerns or aspects that you think I might have overlooked, please let me know.

yuma124 avatar Jan 29 '24 06:01 yuma124