Skip to main content

One post tagged with "v0.2.0"

View All Tags

· 5 min read
Maxwell Miao
Jiandong Wu
Bo Wang
Zhuo Li

Database Mesh

Database Mesh-oriented solutions for an easy-to-use, good-to-use, and practical user experience.

Pisanix version 0.2.0 was recently released. The newly released one supports dynamic read/write splitting. More details below.

Introducing dynamic read/write splitting


Read/write splitting is one of the most commonly used solutions for MySQL's high availability. It improves query performance and reduces server load in practical scenarios. On top of the static rules of v0.1.1, dynamic read/write splitting is added in this release.

Read/write splitting rules need to be configured when it comes to splitting with dynamic awareness. Pisa-Proxy performs SQL routing according to the rules. As shown in Figure 1.1, the Pisa-Proxy backend will start four monitors to sense the backend cluster status.

Monitor Reconcile will calculate and aggregate the data reported by the Monitor and draw the final state of the backend cluster. Then Monitor Reconcile sends the state information to RulesMatch through the channel. RulesMatch dynamically adjusts the backend data source list once it receives the message.

The concepts included above are:

  • Node: Backend database node.
  • RulesMatch: RulesMatch engine matches with the SQL query statements received by Pisa-Proxy based on the written rule set.
  • TargetRole: A TargetRole group matched by the RulesMatch engine. Each TargetRole group may contain one or more nodes.
  • LoadBalance: The load balance module selects an appropriate node from the TargetRole group according to the corresponding algorithm.
  • TargetInstance: Nodes selected by the LoadBalance module.
  • Discovery: Discovery type, which corresponds to the high availability strategy used by the backend data source, such as MHA, RDS, MGR, etc. The newly released version mainly supports MHA.
  • Monitor: It refers to the backend detector module of Pisa-Proxy, which mainly relies on four kinds of Monitors in MHA.
    • Connect Monitor: detect database connectivity.
    • Ping Monitor: detect whether the database is healthy.
    • Replication Lag Monitor: detect the latency status of primary-secondary replication.
    • Read Only Monitor: detect the roles of primary-secondary databases.

Read/write splitting configuration

The configuration mode of dynamic read/write splitting is the same as that of the static one. The configuration items of dynamic read/write splitting are as follows:

ParameterTypeDependency or notDefault ValueDescription
userstringYesNoneDetector module checks the username of SQL statements.
passwordstringYesNoneDetector module checks the password of SQL statements.
monitor_periodu64Yes1000The period (ms) by which detector module updates and senses the backend data source status.
connect_periodu64Yes1000Connect Monitor detection period (ms)
connect_timeoutu64Yes6000Connect Monitor detection timeout (ms)
connect_failure_thresholdu64Yes1Number of retries when Connect Monitor detection fails
ping_periodu64Yes1000Ping Monitor detection period (ms)
ping_timeoutu64Yes6000Ping Monitor detection timeout (ms)
ping_failure_thresholdu64Yes1Number of retries when Ping Monitor detection fails.
replication_lag_periodu64Yes1000Replication Lag Monitor detection period (ms)
replication_lag_timeoutu64Yes6000Replication Lag Monitor detection timeout (ms)
replication_lag_failure_thresholdu64Yes1Number of retries when Replication Lag Monitor detection fails.
max_replication_lagu64Yes10000User-defined maximum primary/secondary latency threshold (ms)
read_only_periodu64Yes1000Read Only detection period (ms)
read_only_timeoutu64Yes6000Read Only detection timeout (ms)
read_only_failure_thresholdu64Yes3Number of retries when Read Only Monitor detection fails.

CRD configuration sample:

kind: TrafficStrategy
name: catalogue
namespace: demotest
source: test
defaultTarget: readwrite
failureThreshold: 3
periodMilliseconds: 1000
timeoutMilliseconds: 6000
monitorPeriod: 1000
failureThreshold: 3
periodMilliseconds: 1000
timeoutMilliseconds: 6000
failureThreshold: 3
periodMilliseconds: 1000
timeoutMilliseconds: 6000
failureThreshold: 3
maxReplicationLag: 3
periodMilliseconds: 1000
timeoutMilliseconds: 6000
user: monitor
password: monitor
- algorithmName: roundrobin
name: write-rule
- ^insert
target: readwrite
type: regex
- algorithmName: roundrobin
name: read-rule
- ^select
target: read
type: regex

Pisanix v0.2.0 Description

New features

  • Pisa-Controller
    • Support dynamic read/write splitting in the TrafficStrategy CRD ReadWriteSplitting field #208
  • Pisa-Proxy
    • Support dynamic read/write splitting #204
    • Add the sub-command: daemonsidecar #190


  • Refactor config files of Pisa-Proxy #182
  • Complete the SHOW SQL statement parsing #183
  • Add code coverage checks to Pisa-Controller #192
  • Enable reconnecting when backend data source fails to be connected #215


  • Pisa-Controller
    • Fix webhook tls #221
  • Pisa-Proxy
    • Fix the request failure to switch MySQL authentication #170
    • Handle exceptions of EOF package of MySQL protocol #166
    • Fix the Charset character set #154
    • Fix the environment variables injection #223


There are 62 PRs in this release. Thanks to the following contributors:

  • mlycore
  • xuanyuan300
  • wbtlb
  • windghoul
  • lltgo
  • tuichenchuxin
  • dongzl

🔗Download link:

Community Call

Building an open source community needs help from everywhere, no matter it's code or documentation, issues or pull requests, community thanks all of your efforts.

At present, there are some ways to join the community:

Mailing List
Dev Meetings (Starting Feb 16th, 2022), Bi-weekly Wednesday 9:00AM PST
Dev Meetings APAC Friendly (Starting April 27th, 2022), Bi-weekly APAC Wednesday 9:00PM GMT+8
Wechat Brokerpisanix
Meetings Notes

Feel free to talk !