-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Motivation ---------- Support changes to index node assignments after an index is created. Modifications ------------- Implemented a phase system for mutations so that different replicas can be moved separately to prevent downtime. Fixed a flaw in the logic using the /indexStatus API to retrieve node assignments for automatic replicas. Created MoveIndexMutation to handle ALTER INDEX statements on 5.5, with support in IndexManager. Created a FeatureVersion class to help manage Couchbase versions where specific features are supported. Return proper mutations for changes to nodes and num_replicas, in both the manual and automatic index mutation forms. Change UpdateIndexMutation to recognize when it's actually a safe mutation based on replicas being present. Results ------- Automatic replica scaling is supported on CB >= 5.0 as an unsafe operation. Automatic replica moving is supported on CB >= 5.5 as a safe operation, moves are skipped with a warning on 5.0 and 5.1. Manual replica scaling and moving is supported, and is safe so long as there is at least one replica. Other update operations, such as index_key and condition, are now safe operations for any index with at least one replica and running in manual replica mode.
- Loading branch information
1 parent
efdbea0
commit e438845
Showing
14 changed files
with
1,009 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* @typedef Version | ||
* @property {number} major | ||
* @property {number} minor | ||
*/ | ||
|
||
/** | ||
* Tests for compatibility with various features, | ||
* given a cluster version from clusterCompatibility. | ||
*/ | ||
export class FeatureVersions { | ||
/** | ||
* Tests for ALTER INDEX compatibility | ||
* | ||
* @param {Version} version | ||
* @return {boolean} | ||
*/ | ||
static alterIndex(version) { | ||
return version && | ||
(version.major > 5 || | ||
(version.major == 5 && version.minor >= 5)); | ||
} | ||
|
||
/** | ||
* Tests for automatic replica compatibility | ||
* | ||
* @param {Version} version | ||
* @return {boolean} | ||
*/ | ||
static autoReplicas(version) { | ||
return version && version.major >= 5; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import {IndexMutation} from './index-mutation'; | ||
import chalk from 'chalk'; | ||
|
||
/** | ||
* @typedef CouchbaseIndex | ||
* @property {string} name | ||
* @property {array.string} index_key | ||
* @property {?string} condition | ||
*/ | ||
|
||
/** | ||
* Represents an index mutation which updates an existing index | ||
*/ | ||
export class MoveIndexMutation extends IndexMutation { | ||
/** | ||
* @param {IndexDefinition} definition Index definition | ||
* @param {string} name Name of the index to mutate | ||
* @param {boolean} unsupported | ||
* If true, don't actually perform this mutation | ||
*/ | ||
constructor(definition, name, unsupported) { | ||
super(definition, name); | ||
|
||
this.unsupported = unsupported; | ||
} | ||
|
||
/** @inheritDoc */ | ||
print(logger) { | ||
const color = this.unsupported ? | ||
chalk.yellowBright : | ||
chalk.cyanBright; | ||
|
||
logger.info(color( | ||
` Move: ${this.name}`)); | ||
|
||
logger.info(color( | ||
` Nodes: ${this.definition.nodes.join()}`)); | ||
|
||
if (this.unsupported) { | ||
logger.info(color( | ||
` Skip: ALTER INDEX is not supported until CB 5.5` | ||
)); | ||
} | ||
} | ||
|
||
/** @inheritDoc */ | ||
async execute(manager, logger) { | ||
if (!this.unsupported) { | ||
await manager.moveIndex(this.name, this.definition.nodes); | ||
} | ||
} | ||
|
||
/** @inheritDoc */ | ||
isSafe() { | ||
return true; | ||
} | ||
} |
Oops, something went wrong.