vitess.io/vitess@v0.16.2/changelog/14.0/14.0.0/summary.md (about) 1 ## Summary 2 3 - [Gen4 is now the default planner](#gen4-is-now-the-default-planner) 4 - [New query support](#new-query-support) 5 - [Command-line syntax deprecations](#command-line-syntax-deprecations) 6 - [New command line flags and behavior](#new-command-line-flags-and-behavior) 7 - [Online DDL changes](#online-ddl-changes) 8 - [Table lifecycle](#table-lifecycle) 9 - [Tablet throttler](#tablet-throttler) 10 - [Heartbeat](#heartbeat) 11 - [VDiff2](#vdiff2) 12 - [Durability Policy](#durability-policy) 13 - [Deprecation of Durability Configuration](#deprecation-of-durability-configuration) 14 - [Advisory locking optimizations](#advisory-locking-optimizations) 15 - [Pre-Legacy Resharding is now deprecated](#pre-legacy-resharding-is-now-deprecated) 16 17 ## Known Issues 18 19 - [VTOrc doesn't discover the tablets](https://github.com/vitessio/vitess/issues/10650) of a keyspace if the durability policy doesn't exist in the topo server when it comes up. This can be resolved by restarting VTOrc. 20 - [Corrupted results for non-full-group-by queries with JOINs](https://github.com/vitessio/vitess/issues/11625). This can be resolved by using full-group-by queries. 21 22 ## Major Changes 23 24 ### Gen4 is now the default planner 25 26 The new planner has been in the works since end of 2020, and it's finally grown enough to be able to become the default planner for Vitess. 27 This means that many more queries are supported on sharded keyspaces, and old queries might get planned better than before. 28 You can always roll back to the earlier planner, either by providing the flag `--planner-version=V3` to `vtgate`, or by adding a comment to individual queries, like so: 29 30 ```sql 31 select /*vt+ PLANNER=V3 */ name, count(*) from users 32 ``` 33 34 ### New query support 35 36 #### Support for aggregation across shards 37 Vitess can now plan and execute most aggregation queries across multiple shards and/or keyspaces. 38 39 #### INSERT from SELECT 40 Support has been added for inserting new data from SELECT queries. 41 Now you can insert data from a query into a table using a query like: 42 43 ```sql 44 insert into tbl (col) select id from users 45 ``` 46 47 #### UPDATE from SELECT 48 Similarly, we have added support for UPDATE with scalar sub-queries. This allows for queries where the updated value is fetched using a subquery, such as this example: 49 50 ```sql 51 update tbl set foo = (select count(*) from otherTbl) 52 ``` 53 54 ### Command-line syntax deprecations 55 56 Vitess has begun a transition to a new library for CLI flag parsing. 57 In order to facilitate a smooth transition, certain syntaxes that will not be supported in the future now issue deprecation warnings when used. 58 59 The messages you will likely see, along with explanations and migrations, are: 60 61 #### "Use of single-dash long flags is deprecated" 62 63 Single-dash usage will be only possible for short flags (e.g. `-v` is okay, but `-verbose` is not). 64 65 To migrate, update your CLI scripts from: 66 67 ``` 68 $ vttablet -tablet_alias zone1-100 -init_keyspace mykeyspace ... # old way 69 ``` 70 71 To: 72 73 ``` 74 $ vttablet --tablet_alias zone1-100 --init_keyspace mykeyspace ... # new way 75 ``` 76 77 #### "Detected a dashed argument after a position argument." 78 79 As the full deprecation text goes on to (attempt to) explain, mixing flags and positional arguments will change in a future version that will break scripts. 80 81 Currently, when invoking a binary like: 82 83 ``` 84 $ vtctl --topo_implementation etcd2 AddCellInfo --root "/vitess/global" 85 ``` 86 87 Everything after the `AddCellInfo` is treated by `package flag` as a positional argument, and we then use a sub FlagSet to parse flags specific to the subcommand. 88 So, at the top-level, `flag.Args()` returns `["AddCellInfo", "--root", "/vitess/global"]`. 89 90 The library we are transitioning to is more flexible, allowing flags and positional arguments to be interwoven on the command-line. 91 For the above example, this means that we would attempt to parse `--root` as a top-level flag for the `VTCtl` binary. 92 This will cause the program to exit on error, because that flag is only defined on the `AddCellInfo` subcommand. 93 94 In order to transition, a standalone double-dash (literally, `--`) will cause the new flag library to treat everything following that as a positional argument, and also works with the current flag parsing code we use. 95 96 So, to transition the above example without breakage, update the command to: 97 98 ```shell 99 $ vtctl --topo_implementation etcd2 AddCellInfo -- --root "/vitess/global" 100 $ # the following will also work 101 $ vtctl --topo_implementation etcd2 -- AddCellInfo --root "/vitess/global" 102 $ # the following will NOT work, because --topo_implementation is a top-level flag, not a sub-command flag 103 $ vtctl -- --topo_implementation etcd2 AddCellInfo --root "/vitess/global" 104 ``` 105 106 ### New command line flags and behavior 107 108 #### vttablet --heartbeat_on_demand_duration 109 110 `--heartbeat_on_demand_duration` joins the already existing heartbeat flags `--heartbeat_enable` and `--heartbeat_interval` and adds new behavior to heartbeat writes. 111 112 `--heartbeat_on_demand_duration` takes a duration value, such as `5s`. 113 114 The default value for `--heartbeat_on_demand_duration` is zero, which means the flag is not set and there is no change in behavior. 115 116 When `--heartbeat_on_demand_duration` has a positive value, then heartbeats are only injected on demand, based on internal requests. For example, when `--heartbeat_on_demand_duration=5s`, the tablet starts without injecting heartbeats. 117 An internal module, like the lag throttler, may request the heartbeat writer for heartbeats. Starting at that point in time, and for the duration (a lease) of `5s` in our example, the tablet will write heartbeats. 118 If no other requests come in during that time, the tablet then ceases to write heartbeats. If more requests for heartbeats come in, the tablet extends the lease for the next `5s` following each request. 119 It stops writing heartbeats `5s` after the last request is received. 120 121 The heartbeats are generated according to `--heartbeat_interval`. 122 123 #### Deprecation of --online_ddl_check_interval 124 125 The flag `--online_ddl_check_interval` is deprecated and will be removed in `v15`. It has been unused in `v13`. 126 127 #### Removal of --gateway_implementation 128 129 In previous releases, the `discoverygateway` was deprecated. In Vitess 14 it is now entirely removed, along with the VTGate flag that allowed us to choose a gateway. 130 131 #### Deprecation of --planner_version 132 133 The flag `--planner_version` is deprecated and will be removed in `v15`. 134 Some binaries used `--planner_version`, and some used `--planner-version`. 135 This has been made consistent - all binaries that allow you to configure the planner now take `--planner-version`. 136 All uses of the underscore form have been deprecated and will be removed in `v15`. 137 138 ### Online DDL changes 139 140 #### Online DDL is generally available 141 142 Online DDL is no longer experimental (with the exception of `pt-osc` strategy). Specifically: 143 144 - Managed schema changes, the scheduler, the backing tables 145 - Supporting SQL syntax 146 - `vitess` strategy (online DDL via VReplication) 147 - `gh-ost` strategy (online DDL via 3rd party `gh-ost`) 148 - Recoverable migrations 149 - Revertible migrations 150 - Declarative migrations 151 - Postponed migrations 152 - And all other functionality 153 154 Are all considered production-ready. 155 156 `pt-osc` strategy (online DDL via 3rd party `pt-online-schema-change`) remains experimental. 157 158 #### ddl_strategy: 'vitess' 159 160 `ddl_strategy` now takes the value of `vitess` to indicate VReplication-based migrations. It is a synonym to `online` and uses the exact same functionality. The `online` term will be phased out in the future and `vitess` will remain the term of preference. 161 162 Example: 163 164 ```shell 165 vtctlclient ApplySchema -skip_preflight -ddl_strategy='vitess' -sql "alter table my_table add column my_val int not null default 0" commerce 166 ``` 167 168 #### --singleton-context and REVERT migrations 169 170 It is now possible to submit a migration with `--singleton-context` strategy flag, while there's a pending (queued or running) `REVERT` migration that does not have a `--singleton-context` flag. 171 172 #### Support for CHECK constraints 173 174 Online DDL operations are more aware of `CHECK` constraints, and properly handle the limitation where a `CHECK`'s name has to be unique in the schema. As opposed to letting MySQL choose arbitrary names for shadow table's `CHECK` constraints, Online DDL now generates unique yet deterministic names, such that all shards converge onto the same names. 175 176 Online DDL attempts to preserve the original check's name as a suffix to the generated name, where possible (names are limited to `64` characters). 177 178 #### Behavior changes 179 180 - `vtctl ApplySchema --uuid_list='...'` now rejects a migration if an existing migration has the same UUID but with different `migration_context`. 181 182 ### Table lifecycle 183 184 #### Views 185 186 Table lifecycle now supports views. It does not purge rows from views, and does not keep views in `EVAC` state (they are immediately transitioned to `DROP` state). 187 188 #### Fast drops 189 190 On Mysql `8.0.23` or later, the states `PURGE` and `EVAC` are automatically skipped, thanks to `8.0.23` improvements to `DROP TABLE` speed of operation. 191 192 ### Tablet throttler 193 194 #### API changes 195 196 Added `/throttler/throttled-apps` endpoint, which reports back all current throttling instructions. Note, this only reports explicit throttling requests (such as ones submitted by `/throtler/throttle-app?app=...`). It does not list incidental rejections based on throttle thresholds. 197 198 API endpoint `/throttler/throttle-app` now accepts a `ratio` query argument, a floating point value in the range `[0..1]`, where: 199 200 - `0` means "do not throttle at all" 201 - `1` means "always throttle" 202 - Any number in between is allowed. For example, `0.3` means "throttle with 0.3 probability", i.e. for any given request there's a 30% chance that the request is denied. Overall we can expect about `30%` of requests to be denied. Example: `/throttler/throttle-app?app=vreplication&ratio=0.25`. 203 204 See new SQL syntax for controlling/viewing throttling, under [New Syntax](#new-syntax). 205 206 #### New Syntax 207 208 ##### Control and view Online DDL throttling 209 210 We introduce the following syntax to: 211 212 - Start/stop throttling for all Online DDL migrations, in general 213 - Start/stop throttling for a particular Online DDL migration 214 - View throttler state 215 216 217 ```sql 218 ALTER VITESS_MIGRATION '<uuid>' THROTTLE [EXPIRE '<duration>'] [RATIO <ratio>]; 219 ALTER VITESS_MIGRATION THROTTLE ALL [EXPIRE '<duration>'] [RATIO <ratio>]; 220 ALTER VITESS_MIGRATION '<uuid>' UNTHROTTLE; 221 ALTER VITESS_MIGRATION UNTHROTTLE ALL; 222 SHOW VITESS_THROTTLED_APPS; 223 ``` 224 225 The default `duration` is "infinite" (set as 100 years): 226 - Allowed units are (s)ec, (m)in, (h)our 227 228 The ratio is in the range `[0..1]`: 229 - `1` means throttle everything - the app will not make any progress 230 - `0` means no throttling at all 231 - `0.8` means on 8 out of 10 checks the app makes, it gets refused 232 233 The syntax `SHOW VITESS_THROTTLED_APPS` is a generic call to the throttler, and returns information about all throttled apps, not specific to migrations. 234 235 The output of `SHOW VITESS_MIGRATIONS ...` now includes `user_throttle_ratio`. 236 237 This column is updated "once in a while", while a migration is running. Normally this is once a minute, but can be more frequent. The migration reports back the throttling instruction set by the user while it was running. 238 This column does not indicate any lag-based throttling that might take place based on the throttler configuration. It only reports the explicit throttling value set by the user. 239 240 ### Heartbeat 241 242 The throttler now checks in with the heartbeat writer to request heartbeats, any time it (the throttler) is asked for a check. 243 244 When `--heartbeat_on_demand_duration` is not set, there is no change in behavior. 245 246 When `--heartbeat_on_demand_duration` is set to a positive value, then the throttler ensures that the heartbeat writer generates heartbeats for at least the following duration. 247 This also means at the first throttler check, it's possible that heartbeats are idle, and so the first check will fail. As heartbeats start running, followup checks will get a more accurate lag evaluation and will respond accordingly. 248 In a sense, it's a "cold engine" scenario, where the engine takes time to start up, and then runs smoothly. 249 250 ### VDiff2 251 252 We introduced a new version of VDiff -- currently marked as EXPERIMENTAL -- that executes the VDiff on vttablets rather than in vtctld. 253 While this is experimental we encourage you to try it out and provide feedback! This input will be invaluable as we improve the feature on the march toward [a production-ready version](https://github.com/vitessio/vitess/issues/10494). 254 You can try it out by adding the `--v2` flag to your VDiff command. Here's an example: 255 ``` 256 $ vtctlclient --server=localhost:15999 VDiff -- --v2 customer.commerce2customer 257 VDiff bf9dfc5f-e5e6-11ec-823d-0aa62e50dd24 scheduled on target shards, use show to view progress 258 259 $ vtctlclient --server=localhost:15999 VDiff -- --v2 customer.commerce2customer show last 260 261 VDiff Summary for customer.commerce2customer (4c664dc2-eba9-11ec-9ef7-920702940ee0) 262 State: completed 263 RowsCompared: 196 264 HasMismatch: false 265 StartedAt: 2022-06-26 22:44:29 266 CompletedAt: 2022-06-26 22:44:31 267 268 Use "--format=json" for more detailed output. 269 270 $ vtctlclient --server=localhost:15999 VDiff -- --v2 --format=json customer.commerce2customer show last 271 { 272 "Workflow": "commerce2customer", 273 "Keyspace": "customer", 274 "State": "completed", 275 "UUID": "4c664dc2-eba9-11ec-9ef7-920702940ee0", 276 "RowsCompared": 196, 277 "HasMismatch": false, 278 "Shards": "0", 279 "StartedAt": "2022-06-26 22:44:29", 280 "CompletedAt": "2022-06-26 22:44:31" 281 } 282 ``` 283 284 > Even before it's marked as production-ready (feature complete and tested widely in 1+ releases), it should be safe to use and is likely to provide much better results for very large tables. 285 286 For additional details please see the [RFC](https://github.com/vitessio/vitess/issues/10134), the [README](https://github.com/vitessio/vitess/blob/release-14.0/go/vt/vttablet/tabletmanager/vdiff/README.md), and the VDiff2 [documentation](https://vitess.io/docs/14.0/reference/vreplication/vdiff2/). 287 288 ### Durability Policy 289 290 #### Deprecation of durability_policy Flag 291 The durability policy for a keyspace is now stored in the keyspace record in the topology server. 292 The `durability_policy` flag used by VTCtl, VTCtld, and VTWorker binaries has been deprecated and will be removed in a future release. 293 294 #### New and Augmented Commands 295 The VTCtld command `CreateKeyspace` has been augmented to take in an additional argument `--durability-policy` which will 296 allow users to set the desired durability policy for a keyspace at creation time. 297 298 For existing keyspaces, a new command `SetKeyspaceDurabilityPolicy` has been added, which allows users to change the 299 durability policy of an existing keyspace. 300 301 If semi-sync is not being used then durability policy should be set to `none` for the keyspace. This is also the default option. 302 303 If semi-sync is being used then durability policy should be set to `semi_sync` for the keyspace and `--enable_semi_sync` should be set on vttablets. 304 305 ### VTOrc - Deprecation of Durability Configuration 306 The `Durability` configuration is deprecated and removed from VTOrc. Instead VTOrc will find the durability policy of the keyspace from 307 the topology server. This allows VTOrc to monitor and repair multiple keyspaces which have different durability policies in use. 308 309 **VTOrc will ignore keyspaces which have no durability policy specified in the keyspace record. This is to avoid clobbering an existing 310 config from a previous release. So on upgrading to v14, users must run the command `SetKeyspaceDurabilityPolicy` specified above, 311 to ensure that VTOrc continues to work as desired. The recommended upgrade 312 path is to upgrade VTCtld, run `SetKeyspaceDurabilityPolicy` and then upgrade VTOrc.** 313 314 ### Advisory locking optimizations 315 Work has gone into making the advisory locks (`get_lock()`, `release_lock()`, etc.) release reserved connections faster and in more situations than before. 316 317 ### Pre-Legacy Resharding is now deprecated 318 A long time ago, the sharding column and type were specified at the keyspace level. This syntax is now deprecated and will be removed in v15.