Skip to content

Commit

Permalink
docs: include PluginManager.releaseResources (#347)
Browse files Browse the repository at this point in the history
  • Loading branch information
sophia-bq authored Dec 6, 2024
1 parent 9cce98e commit 788412f
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/development-guide/PluginManager.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ The plugin manager has the following main functionalities:

The plugin manager initializes all plugins with codes given to the [`plugins`](../using-the-nodejs-wrapper/UsingTheNodejsWrapper.md#connection-plugin-manager-parameters) connection parameter.

### Clean Up Resources

The Aurora Connection Tracker Plugin, Host Monitoring Connection Plugin, and Read/Write Splitting Plugin can have shared resources. The plugin manager handles cleaning up resources that may be shared between connections at the end of an application through the `releaseResources` method.

## Initiate Pipelines

<div style="center"><img src="../images/initiate_pipelines.png" alt="diagram for the plugin service design"/></div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ When the application tries to continue the workflow with the idle connection tha

Since the Aurora Connection Tracker Plugin keeps track of all the open connections, the plugin can close all impacted connections after failover.
When the application tries to use the outdated idle connection, the application will get an error such as `Can't add new command when connection is in closed state` instead.

> [!WARNING]
> Connections with the Aurora Connection Tracker Plugin may have cached resources used throughout multiple connections. To clean up any resources used by the plugins at the end of the application call `await PluginManager.releaseResources()`.
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,6 @@ await client.connect();
> We recommend you either disable the Host Monitoring Connection Plugin or avoid using RDS Proxy endpoints when the Host Monitoring Connection Plugin is active.
>
> Although using RDS Proxy endpoints with the AWS Advanced NodeJS Wrapper with Enhanced Failure Monitoring doesn't cause any critical issues, we don't recommend this approach. The main reason is that RDS Proxy transparently re-routes requests to a single database instance. RDS Proxy decides which database instance is used based on many criteria (on a per-request basis). Switching between different instances makes the Host Monitoring Connection Plugin useless in terms of instance health monitoring because the plugin will be unable to identify which instance it's connected to, and which one it's monitoring. This could result in false positive failure detections. At the same time, the plugin will still proactively monitor connectivity to RDS Proxy endpoints and report outages back to a user application if they occur.
> [!WARNING]
> Connections with the Host Monitoring Connection Plugin may have cached resources used throughout multiple connections. To clean up any resources used by the plugins at the end of the application call `await PluginManager.releaseResources()`.
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,6 @@ await client.connect();
const client = new AwsPGClient(params);
await client.connect();
```

> [!WARNING]
> Connections with the Read/Write Splitting Plugin may have cached resources used throughout multiple connections. To clean up any resources used by the plugins at the end of the application call `await PluginManager.releaseResources()`.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { ConnectionProviderManager } from "../../common/lib/connection_provider_
import { InternalPooledConnectionProvider } from "../../common/lib/internal_pooled_connection_provider";
import { logger } from "../../common/logutils";
import { AwsPGClient } from "../../pg/lib";
import { PluginManager } from "../../common/lib";

const postgresHost = "db-identifier.XYZ.us-east-2.rds.amazonaws.com";
const username = "john_smith";
Expand Down Expand Up @@ -91,3 +92,6 @@ try {
} finally {
logger.debug("example complete");
}

// Clean up resources used by the plugins.
await PluginManager.releaseResources();
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { AwsMySQLClient } from "../../mysql/lib";
import { ConnectionProviderManager } from "../../common/lib/connection_provider_manager";
import { InternalPooledConnectionProvider } from "../../common/lib/internal_pooled_connection_provider";
import { logger } from "../../common/logutils";
import { PluginManager } from "../../common/lib";

const mysqlHost = "db-identifier.XYZ.us-east-2.rds.amazonaws.com";
const username = "john_smith";
Expand Down Expand Up @@ -91,3 +92,6 @@ try {
} finally {
logger.debug("example complete");
}

// Clean up resources used by the plugins.
await PluginManager.releaseResources();
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { WrapperProperties } from "../../common/lib/wrapper_property";
import { InternalPooledConnectionProvider } from "../../common/lib/internal_pooled_connection_provider";
import { ConnectionProviderManager } from "../../common/lib/connection_provider_manager";
import { AwsPoolConfig } from "../../common/lib/aws_pool_config";
import { PluginManager } from "../../common/lib";

const mysqlHost = "db-identifier.XYZ.us-east-2.rds.amazonaws.com";
const username = "john_smith";
Expand Down Expand Up @@ -137,3 +138,6 @@ async function queryWithFailoverHandling(client: AwsMySQLClient, query: string)
}
}
}

// Clean up resources used by the plugins.
await PluginManager.releaseResources();
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { InternalPoolMapping } from "../../common/lib/utils/internal_pool_mappin
import { ConnectionProviderManager } from "../../common/lib/connection_provider_manager";
import { WrapperProperties } from "../../common/lib/wrapper_property";
import { AwsPoolConfig } from "../../common/lib/aws_pool_config";
import { PluginManager } from "../../common/lib";

const postgresHost = "db-identifier.XYZ.us-east-2.rds.amazonaws.com";
const username = "john_smith";
Expand Down Expand Up @@ -137,3 +138,6 @@ async function queryWithFailoverHandling(client: AwsPGClient, query: string) {
}
}
}

// Clean up resources used by the plugins.
await PluginManager.releaseResources();
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import { AwsMySQLClient } from "../../mysql/lib";
import { FailoverFailedError, FailoverSuccessError, TransactionResolutionUnknownError } from "../../common/lib/utils/errors";
import { PluginManager } from "../../common/lib";

const mysqlHost = "db-identifier.XYZ.us-east-2.rds.amazonaws.com";
const username = "john_smith";
Expand Down Expand Up @@ -105,3 +106,6 @@ async function queryWithFailoverHandling(client: AwsMySQLClient, query: string)
}
}
}

// Clean up resources used by the plugins.
await PluginManager.releaseResources();
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import { AwsPGClient } from "../../pg/lib";
import { FailoverFailedError, FailoverSuccessError, TransactionResolutionUnknownError } from "../../common/lib/utils/errors";
import { PluginManager } from "../../common/lib";

const postgresHost = "db-identifier.XYZ.us-east-2.rds.amazonaws.com";
const username = "john_smith";
Expand Down Expand Up @@ -105,3 +106,6 @@ async function queryWithFailoverHandling(client: AwsPGClient, query: string) {
}
}
}

// Clean up resources used by the plugins.
await PluginManager.releaseResources();

0 comments on commit 788412f

Please sign in to comment.