pecl:mysqlnd_ms
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
pecl:mysqlnd_ms [2012/04/17 14:14] – [Raw Bin ideas (RFCs)] uw | pecl:mysqlnd_ms [2012/04/23 12:02] – [Development steps (release planning)] uw | ||
---|---|---|---|
Line 165: | Line 165: | ||
* [open] Automatic on-connect fail over, if activated, shall be done in a loop until a connection can be opened. Currently we stop after the first attempt. If automatic fail over is on, we try " | * [open] Automatic on-connect fail over, if activated, shall be done in a loop until a connection can be opened. Currently we stop after the first attempt. If automatic fail over is on, we try " | ||
* [open] Remember failed hosts for the duration of a web request (the plugins' | * [open] Remember failed hosts for the duration of a web request (the plugins' | ||
+ | * [open] Add failover timeout and failover (maximum) attempts limits/ | ||
* [open] Support directing statements manually to a group of nodes for more efficient server cache usage | * [open] Support directing statements manually to a group of nodes for more efficient server cache usage | ||
Line 173: | Line 174: | ||
* [open] Improve load balancing | * [open] Improve load balancing | ||
* [open] Allow users to set a ratio/ | * [open] Allow users to set a ratio/ | ||
+ | |||
+ | * [in progress] Improve lazy connection charset handling | ||
* [open] Work with php.net Windows team to provide PECL/ | * [open] Work with php.net Windows team to provide PECL/ | ||
+ | * Ensure the code builds | ||
+ | * Encourage Windows team to create builds | ||
== QA == | == QA == | ||
Line 216: | Line 221: | ||
== Problem to solve / Idea == | == Problem to solve / Idea == | ||
== Feature description == | == Feature description == | ||
- | |||
- | === Eventual consistent: automatic chaining of PECL/ | ||
- | == Problem to solve / Idea == | ||
- | |||
- | MySQL replication is asynchronous. Slaves are //eventual consistent// | ||
- | |||
- | MySQL replication used for read scale-out requires applications to be able to cope with stale data. If stale data is acceptable, a replication system may replace a MySQL slave read access with an access to a local, eventually stale, cache. **The cache access will lower network latency resulting in faster reply to the query. Furthermore, | ||
- | |||
- | For certain queries, PECL/ | ||
- | |||
- | (MySQL semi-synchronous replication does not change the matter as it requires only one slave to have received but not yet applied the update.) | ||
- | |||
- | **PECL/ | ||
- | |||
- | == Feature description == | ||
- | |||
- | Applications shall be able to define a " | ||
- | |||
- | * [RW_]CONSISTENT | ||
- | * [RO_]EVENTUAL_CONSISTENT | ||
- | |||
- | With CONSISTENT every statement shall be run on the master to avoid stale data. EVENTUAL_CONSISTENT allows the use of slaves and thus, stale, non-consistent data may be read. | ||
- | |||
- | PECL/ | ||
- | |||
- | However, PECL/ | ||
- | |||
- | /* Force use of master - consistent read although no SQL hint is used */ | ||
- | mysqlnd_ms_set_service_level($link, | ||
- | $link-> | ||
- | $link-> | ||
- | | ||
- | /* Use master or slaves for reads - allow read stale, non-consistent data is acceptable */ | ||
- | mysqlnd_ms_set_service_level($link, | ||
- | $link-> | ||
- | | ||
- | The service level EVENTUAL_CONSISTENT can be combined with automatic, local caching. It shall be configurable if and for which queries caching shall be used. Configuration can, for example, be done via the PECL/ | ||
- | |||
- | If PECL/ | ||
- | |||
- | Use and integration of PECL/ | ||
- | |||
- | |||
- | === Global Transaction ID === | ||
- | == Problem to solve / Idea == | ||
- | |||
- | In the scope of MySQL master - slave replication global transaction IDs can be understood as a measure to identify a database state. Replicas/ | ||
- | |||
- | The MySQL built-in replication does not feature global transaction IDs. MySQL replication uses transaction log files and log file positions to identify change sets that replicas (slaves) need to apply. Log file and log file position are local to a machine. A tuple of (log file, log file position) does not uniquely identify a change set in the whole cluster. | ||
- | |||
- | If, for example, your setup is A -> B -> C (A is the master, B is a slave reading from A, C is a slave reading from B) and B fails you are faced with the challenge to identify the log file and log file position on A from which C shall continue to read and apply change sets. C cannot continue reading from the same (log file, log position) as it was reading from B. The tuple (log file=2, log position=17) on B can identify a different change set than the tuple (log file=2, log position=17) on A. C might get out of sync, loose change sets or apply them multiple times, if it would blindly continue reading from the same position on A. | ||
- | |||
- | Today, it can become a bit of a time consuming guessing game to identify the next change set that B needs to process in this fail-over example. | ||
- | |||
- | Fail-over and circular-replication is much easier to do if the database cluster maintains a global transaction ID. | ||
- | |||
- | The plugin shall inject SQL to manually maintain a global transaction ID on the master. | ||
- | |||
- | == Feature description == | ||
- | |||
- | Global transaction IDs can be used for multiple purposes: | ||
- | |||
- | * Simplify server fail-over (server-side, | ||
- | |||
- | * Monitor slave replication status (client-side, | ||
- | * Identify " | ||
- | * Identify slaves which are " | ||
- | * Let the load balancer skip slaves which have fallen to far behind to reduce their load | ||
- | |||
- | The plugin shall support using a global transaction ID for: | ||
- | |||
- | - server fail-over (e.g. promoting new master after master failure) | ||
- | - selection of " | ||
- | |||
- | Gobal transaction ID generation shall be done by SQL injection. The plugin shall insert SQL at the end of each (write) transaction (see http:// | ||
- | |||
- | The SQL used for globals transaction ID generation can be different for the different purposes. It may be good enough to inject SET @_g_trx_id=UUID_SHORT() on the master before a SQL transaction commits to help with fail-over. Whereas the selection of slaves of a certain state (" | ||
- | |||
- | Thus, the user shall be able to configure: | ||
- | |||
- | * SQL used for ID generation | ||
- | * SQL used to retrieve ID | ||
- | |||
- | If no SQL is given to retrieve the ID, the plugin does not feature '2) selection of " | ||
- | |||
- | This is useful if, for example, an application does a write and needs to read the modified data " | ||
- | |||
- | /* write to master */ | ||
- | $link-> | ||
- | $write_trx_id = mysqlnd_ms_get_last_global_transaction_id(); | ||
- | | ||
- | /* Force use of master - consistent read although no SQL hint is used */ | ||
- | mysqlnd_ms_set_service_level($link, | ||
- | $link-> | ||
- | $link-> | ||
- | |||
- | /* Read from a slave which has replicated global transaction ID or, if no slave found, use master */ | ||
- | mysqlnd_ms_set_service_level($link, | ||
- | $link-> | ||
- | $link-> | ||
- | | ||
- | /* Use master or slaves for reads - allow read stale, non-consistent data is acceptable */ | ||
- | mysqlnd_ms_set_service_level($link, | ||
- | $link-> | ||
- | |||
- | The global transaction ID feature of the plugin is turned off by default. The feature is seen as an experts topic. | ||
- | |||
- | === mysqlnd_ms_change_user() === | ||
- | == Problem to solve / Idea == | ||
- | |||
- | Give users a way to overrule all automatic decisions, including the use of host credentials from the config when broadcasting COM_CHANGE_USER after mysqlnd_change_user(master_user, | ||
- | |||
- | == Feature description == | ||
- | |||
- | bool mysqlnd_ms_change_user(mixed $connection, | ||
- | | ||
- | $where: MYSQLND_MS_ALL_CONNECTIONS, | ||
- | | ||
- | Consider: | ||
- | |||
- | $where: MYSQLND_MS_ALL_CONNECTIONS, | ||
- | |||
- | === mysqlnd_ms_get_errors() === | ||
- | == Problem to solve / Idea == | ||
- | |||
- | Not all MS errors can be bubbled up through the standard APIs. For example, failing to parse parts of the MS config may result in connection error. Upon connect, the user will get the error code for the failed connect. However, the failure to parse the config, the cause of the problem, is only shown as a warning. | ||
- | |||
- | == Feature description == | ||
- | |||
- | array mysqlnd_ms_get_errors([mixed $connection]) | ||
- | | ||
- | TDB. | ||
=== More fail over configuration options === | === More fail over configuration options === |
pecl/mysqlnd_ms.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1