diff --git a/CHANGELOG.md b/CHANGELOG.md index 681038afd..092bd5973 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ [1]: https://www.npmjs.com/package/nodejs-spanner?activeTab=versions +## [6.15.0](https://github.com/googleapis/nodejs-spanner/compare/v6.14.0...v6.15.0) (2023-08-04) + + +### Features + +* Enable leader aware routing by default. This update contains performance optimisations that will reduce the latency of read/write transactions that originate from a region other than the default leader region. ([6852d99](https://github.com/googleapis/nodejs-spanner/commit/6852d99b858eb323ac3fc5e61905b8bf59486062)) + ## [6.14.0](https://github.com/googleapis/nodejs-spanner/compare/v6.13.0...v6.14.0) (2023-07-21) diff --git a/package.json b/package.json index 4e948cc35..39b3b5cd8 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/spanner", "description": "Cloud Spanner Client Library for Node.js", - "version": "6.14.0", + "version": "6.15.0", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index bbd9e78e4..2bfc78d63 100644 --- a/samples/package.json +++ b/samples/package.json @@ -16,7 +16,7 @@ "dependencies": { "@google-cloud/kms": "^3.0.0", "@google-cloud/precise-date": "^3.0.0", - "@google-cloud/spanner": "^6.14.0", + "@google-cloud/spanner": "^6.15.0", "yargs": "^17.0.0" }, "devDependencies": { diff --git a/src/index.ts b/src/index.ts index 558382ba7..76eccc6b3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -108,8 +108,8 @@ export type GetInstanceConfigOperationsCallback = PagedCallback< /** * Session pool configuration options. - * @property {boolean} [routeToLeaderEnabled=False] If set to true leader aware routing will be enabled. - * Enabling leader aware routing would route all requests in RW/PDML transactions to leader region. + * @property {boolean} [routeToLeaderEnabled=True] If set to false leader aware routing will be disabled. + * Disabling leader aware routing would route all requests in RW/PDML transactions to any region. */ export interface SpannerOptions extends GrpcClientOptions { apiEndpoint?: string; @@ -216,7 +216,7 @@ class Spanner extends GrpcService { projectIdReplaced_: boolean; projectFormattedName_: string; resourceHeader_: {[k: string]: string}; - routeToLeaderEnabled = false; + routeToLeaderEnabled = true; /** * Placeholder used to auto populate a column with the commit timestamp. @@ -318,8 +318,8 @@ class Spanner extends GrpcService { } as {} as GrpcServiceConfig; super(config, options); - if (options.routeToLeaderEnabled === true) { - this.routeToLeaderEnabled = true; + if (options.routeToLeaderEnabled === false) { + this.routeToLeaderEnabled = false; } this.options = options; diff --git a/test/spanner.ts b/test/spanner.ts index 322566389..2ca4697f0 100644 --- a/test/spanner.ts +++ b/test/spanner.ts @@ -1491,14 +1491,14 @@ describe('Spanner with mock server', () => { }); describe('LeaderAwareRouting', () => { - let spannerWithLAREnabled: Spanner; - let instanceWithLAREnabled: Instance; + let spannerWithLARDisabled: Spanner; + let instanceWithLARDisabled: Instance; - function newTestDatabaseWithLAREnabled( + function newTestDatabaseWithLARDisabled( options?: SessionPoolOptions, queryOptions?: IQueryOptions ): Database { - return instanceWithLAREnabled.database( + return instanceWithLARDisabled.database( `database-${dbCounter++}`, options, queryOptions @@ -1506,18 +1506,18 @@ describe('Spanner with mock server', () => { } before(() => { - spannerWithLAREnabled = new Spanner({ + spannerWithLARDisabled = new Spanner({ servicePath: 'localhost', port, sslCreds: grpc.credentials.createInsecure(), - routeToLeaderEnabled: true, + routeToLeaderEnabled: false, }); // Gets a reference to a Cloud Spanner instance and database - instanceWithLAREnabled = spannerWithLAREnabled.instance('instance'); + instanceWithLARDisabled = spannerWithLARDisabled.instance('instance'); }); it('should execute with leader aware routing enabled in a read/write transaction', async () => { - const database = newTestDatabaseWithLAREnabled(); + const database = newTestDatabase(); await database.runTransactionAsync(async tx => { await tx!.runUpdate({ sql: insertSql, @@ -1539,7 +1539,7 @@ describe('Spanner with mock server', () => { }); it('should execute with leader aware routing disabled in a read/write transaction', async () => { - const database = newTestDatabase(); + const database = newTestDatabaseWithLARDisabled(); await database.runTransactionAsync(async tx => { await tx!.runUpdate({ sql: insertSql,