## Description
**Problem statement:**
In one of the instances where dynamoDB had close to 200 odd queries on
top of it, queries were timing out after a month or so, this happened 3
times with one of the users, where after a month, queries would suddenly
start timing out. One of the hunches was that since we create
dynamoDBclient object only once during datasource creation, it could be
getting stale thus resulting in query timeouts and with that hunch, we
decided to add a fix where we close the old connections regularly after
using for a day.
**Solution:**
This PR configures connection time to live property for DynamoDB plugin.
This is configured to be 1 day which means after 1 day, active/idle
connections will be closed. This is done to ensure that we don't face
issues if the connection becomes stale. Default value of connection time
to live is 0 which means the connection stays open for infinite amount
of time.
To ensure that we do not cause any issues due to introduction of this
property, we decided to add this behind a feature flag. All the feature
flagging related code exists at the `appsmith-server` module but
dynamoDb code exists in `appsmith-plugins -> dynamoDB` module, so in
order to provide feature flagging, ideally we should make feature
flagging service available at `appsmith-interface` module to ensure that
it can get consumed across different modules but that's a [known tech
debt](https://github.com/appsmithorg/appsmith/issues/39425) which we
should resolve soon, but in the meantime to expedite the fix, I have
passed in flag details to respective datasourceCreate functionality.
datasourceCreate also gets called from testDatasource, so feature
flagging has been implemented there as well.
At some point in time, based on whether this potential fix works or not,
we should plan to remove the feature flagging code, task for that added
[here](https://github.com/appsmithorg/appsmith/issues/39426)
**References:**
-
https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/http/apache/ApacheHttpClient.Builder.html#connectionTimeToLive(java.time.Duration)
-
https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/http/SdkHttpConfigurationOption.html#CONNECTION_TIME_TO_LIVE
- https://github.com/aws/aws-sdk-java/issues/2788
Fixes #[`Issue
Number`](https://github.com/appsmithorg/appsmith-ee/issues/6030)
_or_
Fixes `Issue URL`
> [!WARNING]
> _If no issue exists, please create an issue first, and check with the
maintainers if the issue is valid._
## Automation
/ok-to-test tags="@tag.Datasource"
### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results -->
> [!TIP]
> 🟢🟢🟢 All cypress tests have passed! 🎉🎉🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/13515219987>
> Commit: 953e570b2e153087fa7b27c8c24cb50f74333159
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=13515219987&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Datasource`
> Spec:
> <hr>Tue, 25 Feb 2025 07:21:25 UTC
<!-- end of auto-generated comment: Cypress test results -->
## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [x] No
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
- **New Features**
- Enhanced DynamoDB plugin connection management with configurable
connection time-to-live
- Added Apache HTTP client support for improved network connection
handling
- **Dependencies**
- Updated Apache client dependency to version 2.15.3
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: “sneha122” <“sneha@appsmith.com”>