Shadow Algorithm

Background

The shadow DB feature carries out shadow measurement to SQL statements executed. Shadow measurement supports two types of algorithms, and users can choose one or a combination of them based on actual business needs.

Parameters

Column-based shadow algorithm

Column value matching shadow algorithm

Type:VALUE_MATCH

Attribute NameData TypeDescription
columnStringshadow column
operationStringSQL operation type (INSERT, UPDATE, DELETE, SELECT)
valueStringvalue matched by shadow column

Column-based Regex matching algorithm

Type:REGEX_MATCH

Attribute NameData TypeDescription
columnStringmatch a column
operationStringSQL operation type(INSERT, UPDATE, DELETE, SELECT)
regexStringshadow column matching Regex

Hint-based shadow algorithm

SQL HINT shadow algorithm

Type:SQL_HINT

  1. /* SHARDINGSPHERE_HINT: SHADOW=true */

Configuration sample

  • Java API
  1. public final class ShadowConfiguration {
  2. // ...
  3. private AlgorithmConfiguration createShadowAlgorithmConfiguration() {
  4. Properties userIdInsertProps = new Properties();
  5. userIdInsertProps.setProperty("operation", "insert");
  6. userIdInsertProps.setProperty("column", "user_id");
  7. userIdInsertProps.setProperty("value", "1");
  8. return new AlgorithmConfiguration("VALUE_MATCH", userIdInsertProps);
  9. }
  10. // ...
  11. }
  • YAML:
  1. shadowAlgorithms:
  2. user-id-insert-algorithm:
  3. type: VALUE_MATCH
  4. props:
  5. column: user_id
  6. operation: insert
  7. value: 1