Skip to content

Commit

Permalink
fix: failover2 with rw splitting
Browse files Browse the repository at this point in the history
  • Loading branch information
sophia-bq committed Jan 22, 2025
1 parent 290bcb1 commit 720eebe
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions common/lib/plugins/read_write_splitting_plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { ClientWrapper } from "../client_wrapper";
import { getWriter, logAndThrowError } from "../utils/utils";
import { CanReleaseResources } from "../can_release_resources";
import { PoolClientWrapper } from "../pool_client_wrapper";
import { Failover2Plugin } from "./failover2/failover2_plugin";

export class ReadWriteSplittingPlugin extends AbstractConnectionPlugin implements CanReleaseResources {
private static readonly subscribedMethods: Set<string> = new Set(["initHostProvider", "connect", "notifyConnectionChanged", "query"]);
Expand Down Expand Up @@ -196,7 +197,9 @@ export class ReadWriteSplittingPlugin extends AbstractConnectionPlugin implement
const props = new Map(this._properties);
props.set(WrapperProperties.HOST.name, writerHost.host);
try {
const targetClient = await this.pluginService.connect(writerHost, props);
const copyProps = new Map<string, any>(props);
copyProps.set(Failover2Plugin.INTERNAL_CONNECT_PROPERTY_NAME, true);
const targetClient = await this.pluginService.connect(writerHost, copyProps);
this.isWriterClientFromInternalPool = targetClient instanceof PoolClientWrapper;
this.setWriterClient(targetClient, writerHost);
await this.switchCurrentTargetClientTo(this.writerTargetClient, writerHost);
Expand Down Expand Up @@ -289,7 +292,9 @@ export class ReadWriteSplittingPlugin extends AbstractConnectionPlugin implement
props.set(WrapperProperties.HOST.name, host.host);

try {
targetClient = await this.pluginService.connect(host, props);
const copyProps = new Map<string, any>(props);
copyProps.set(Failover2Plugin.INTERNAL_CONNECT_PROPERTY_NAME, true);
targetClient = await this.pluginService.connect(host, copyProps);
this.isReaderClientFromInternalPool = targetClient instanceof PoolClientWrapper;
readerHost = host;
break;
Expand Down

0 comments on commit 720eebe

Please sign in to comment.