|
| 1 | +Tarantool 3.4 |
| 2 | +============= |
| 3 | + |
| 4 | +Release date: April 14, 2024 |
| 5 | + |
| 6 | +Releases on GitHub: :tarantool-release:`3.4.0` |
| 7 | + |
| 8 | +The 3.4 release of Tarantool adds the following main product features and improvements |
| 9 | +for the Community and Enterprise editions: |
| 10 | + |
| 11 | +* **Community Edition (CE)** |
| 12 | + |
| 13 | + * Memtx-vinyl cross-engine transactions. |
| 14 | + * New ``index:quantile()`` function for finding a quantile key in an indexed data range. |
| 15 | + * Functional indexes in the MVCC transaction manager. |
| 16 | + * Vinyl now supports ``np`` (next prefix) and ``pp`` (previous prefix) iterators. |
| 17 | + * Fixed incorrect number comparisons and duplicates in unique indexes. |
| 18 | + * Runtime priviledges for ``lua_call`` are now granted before ``box.cfg()``. |
| 19 | + * The ``stop`` callbacks for the roles are now called during graceful shutdown, |
| 20 | + in the reverse order of roles startup. |
| 21 | + * New ``has_role``, ``is_router``, and ``is_storage`` methods in the |
| 22 | + ``config`` module to check if a role is enabled on an instance. |
| 23 | + * LuaJIT profilers are now more user-friendly. |
| 24 | + * Built-in logger now encodes table arguments in the JSON format. |
| 25 | + * Multiple bugfixes for MVCC, vinyl, WAL, and snapshotting. |
| 26 | + * Fixed memory overgrowing for cdata-intensive workloads. |
| 27 | + |
| 28 | +* **Enterprise Edition (EE)** |
| 29 | + |
| 30 | + * New in-memory columnar storage engine: ``memcs``. |
| 31 | + * New bootstrap strategy in failover: ``native``. |
| 32 | + * New public API for accessing remote ``config.storage`` clusters as key-value storages. |
| 33 | + * Two-phase appointment process to avoid incorrect behavior of the failover coordinator. |
| 34 | + |
| 35 | +.. _3-4-memcs: |
| 36 | + |
| 37 | +[EE] New in-memory columnar storage engine: ``memcs`` |
| 38 | +----------------------------------------------------- |
| 39 | + |
| 40 | +The engine stores data in the memtx arena but in contrast to memtx it doesn't |
| 41 | +organize data in tuples. Instead, it stores data in columns. Each format field |
| 42 | +is assigned its own BPS tree-like structure (BPS vector), which stores values |
| 43 | +only of that field. If the field type fits in 8 bytes, raw field values are |
| 44 | +stored directly in tree leaves without any encoding. For values larger than 8 |
| 45 | +bytes, like decimal, uuid or strings, the leaves store pointers to |
| 46 | +MsgPack-encoded data. |
| 47 | + |
| 48 | +The main benefit of such data organization is a significant performance boost |
| 49 | +of columnar data sequential scans compared to memtx thanks to CPU cache |
| 50 | +locality. That's why memcs supports a special C api for such columnar scans: |
| 51 | +see `box_index_arrow_stream()` and `box_raw_read_view_arrow_stream()`. |
| 52 | +Peak performance is achieved when scanning embedded field types. |
| 53 | + |
| 54 | +Querying full tuples, like in memtx, is also supported, but the performance is |
| 55 | +worse compared to memtx, because a tuple has to be constructed on the runtime |
| 56 | +arena from individual field values gathered from each column tree. |
| 57 | + |
| 58 | +Other features include: |
| 59 | +* Point lookup. |
| 60 | +* Stable iterators. |
| 61 | +* Insert/replace/delete/update. |
| 62 | +* Batch insertion in the Arrow format. |
| 63 | +* Transactions, including cross-engine transactions with memtx |
| 64 | + (with ``memtx_use_mvcc_engine = false``). |
| 65 | +* Read view support. |
| 66 | +* Secondary indexes with an ability to specify covered columns and sequentially scan |
| 67 | + indexed + covered columns. |
| 68 | + |
| 69 | +Embedded field types include only fixed-width types: |
| 70 | +* Integer: (u)int8/16/32/64. |
| 71 | +* Floating point: float32/64. |
| 72 | + |
| 73 | +Types with external storage include: |
| 74 | +* Strings. |
| 75 | +* All the other types supported by Tarantool: UUID, Decimal, Datetime, etc. |
| 76 | + |
| 77 | +By default, NULL values are stored explicitly and use up the same space as |
| 78 | +any other valid column value (1, 2, 4 or 8 bytes depending on an exact field |
| 79 | +type), however RLE encoding of NULLs is also supported. For reference, |
| 80 | +RLE-encoding of a column with 90% evenly distributed NULL values reduces |
| 81 | +memory consumption of that column by around 5 times. |
| 82 | + |
| 83 | +.. _3-4-cross-engine: |
| 84 | + |
| 85 | +[CE] Memtx-vinyl cross-engine transactions |
| 86 | +----------------------------------------------- |
| 87 | + |
| 88 | +Tarantool now supports mixing statements for memtx and vinyl in the same transaction, |
| 89 | +for example: |
| 90 | + |
| 91 | +.. code-block:: lua |
| 92 | +
|
| 93 | + local memtx = box.schema.space.create('memtx', {engine = 'memtx'}) |
| 94 | + memtx:create_index('primary') |
| 95 | + local vinyl = box.schema.space.create('vinyl', {engine = 'vinyl'}) |
| 96 | + vinyl:create_index('primary') |
| 97 | +
|
| 98 | + memtx:insert({1, 'a'}) |
| 99 | + vinyl:insert({2, 'b'}) |
| 100 | +
|
| 101 | + box.begin() |
| 102 | + memtx:replace(vinyl:get(2)) |
| 103 | + vinyl:replace(memtx:get(1)) |
| 104 | + box.commit() |
| 105 | +
|
| 106 | +.. note:: |
| 107 | + |
| 108 | + * Accessing a vinyl space may trigger a fiber yield (to read a file from the disk), |
| 109 | + so MVCC must be enabled in memtx to make use of the new feature: |
| 110 | + |
| 111 | + .. code-block:: lua |
| 112 | +
|
| 113 | + box.cfg{memtx_use_mvcc_engine = true} |
| 114 | +
|
| 115 | + * Vinyl operations may yield implicitly, so a transaction may be aborted |
| 116 | + with TRANSACTION_CONFLICT in case of concurrent transactions. |
| 117 | + |
| 118 | +.. _3-4-native: |
| 119 | + |
| 120 | +[EE] New boostrap strategy in failover: ``native`` |
| 121 | +-------------------------------------------------- |
| 122 | + |
| 123 | +Now supervised failover coordinator supports three bootstrap strategies: |
| 124 | +native, supervised, auto. |
| 125 | + |
| 126 | +The new ``native`` strategy relaxes the limitations of the ``auto`` strategy, |
| 127 | +but has different under-the-hood implementation (based on the ``supervised`` strategy). |
| 128 | +Otherwise, it acts similar to the ``auto`` strategy. |
| 129 | + |
| 130 | +In effect, it helps resolve these two problems: |
| 131 | +* Avoid the error ``Some replica set members were not specified in box.cfg.replication`` |
| 132 | + in the following cases: |
| 133 | + * several replicas join at the same time, |
| 134 | + * the replica set includes non-anonymous CDC instances, |
| 135 | + * ``_cluster`` contains old unneeded replicas. |
| 136 | +* Make the database get bootstrapped upon the coordinator's command rather than |
| 137 | + let the instances boostrap it on their own. |
| 138 | + |
| 139 | +This strategy is the recommended choice for highly dynamic clusters with automatic |
| 140 | +scaling, as well as in most other cases. |
| 141 | + |
| 142 | +To enable the ``native`` bootstrap strategy, set it in the ``replication`` section |
| 143 | +of the cluster's configuration, together with a proper failover strategy |
| 144 | +(for ``native``, you can choose any failover strategy you like, for example ``supervised``): |
| 145 | + |
| 146 | +.. code-block:: yaml |
| 147 | +
|
| 148 | + replication: |
| 149 | + failover: supervised |
| 150 | + bootstrap_strategy: native |
| 151 | +
|
| 152 | +.. _3-4-runtime-priv: |
| 153 | + |
| 154 | +[CE] Runtime priviledges for ``lua_call`` granted before ``box.cfg()`` |
| 155 | +---------------------------------------------------------------------- |
| 156 | + |
| 157 | +It is now possible to grant execution privileges for Lua functions |
| 158 | +through the declarative configuration, even when the database is in |
| 159 | +read-only mode or has an outdated schema version. You might also |
| 160 | +permit ``guest`` to execute Lua functions before the initial bootstrap. |
| 161 | + |
| 162 | +You can specify function permissions using the ``lua_call`` option in |
| 163 | +the configuration, for example: |
| 164 | + |
| 165 | +.. code-block:: lua |
| 166 | +
|
| 167 | + credentials: |
| 168 | + users: |
| 169 | + alice: |
| 170 | + privileges: |
| 171 | + - permissions: [execute] |
| 172 | + lua_call: [my_func] |
| 173 | +
|
| 174 | +This grants the ``alice`` user permission to execute the ``my_func`` Lua |
| 175 | +function, regardless of the database's mode or status. The special option |
| 176 | +``lua_call: [all]`` is also supported, granting access to all global Lua |
| 177 | +functions except built-in ones, bypassing database restrictions. |
| 178 | + |
| 179 | +Privileges will still be written to the database when possible to |
| 180 | +maintain compatibility and consistency with other privilege types. |
| 181 | + |
| 182 | +[CE] New methods in the ``config`` module to check instance roles |
| 183 | +----------------------------------------------------------------- |
| 184 | + |
| 185 | +Three new methods are now available in the ``config`` module: |
| 186 | + |
| 187 | +* ``config:has_role('myrole')`` tells whether the current instance has the role ``myrole``, and |
| 188 | + ``config:has_role('myrole', {instance = 'i-001'})`` does the same for the specified instance (``i-001``). |
| 189 | + |
| 190 | +* ``config:is_router()`` tells whether the current instance is a vshard router, and |
| 191 | + ``config:is_router({instance = 'i-002'})`` does the same for the specified instance (``i-002``). |
| 192 | + |
| 193 | +* ``config:is_storage()`` tells whether the current instance is a vshard storage, and |
| 194 | + ``config:is_storage({instance = 'i-003'})`` does the same for the specified instance (``i-003``). |
| 195 | + |
| 196 | +.. _3-4-storage-client-api: |
| 197 | + |
| 198 | +[EE] New public API: ``config.storage_client`` |
| 199 | +---------------------------------------------- |
| 200 | + |
| 201 | +Remote ``config.storage`` clusters can now be accessed by using the |
| 202 | +``config.storage_client.connect(endpoints[, {options}])`` method. |
| 203 | +The returned object represents a connection to a remote key-value |
| 204 | +storage accessed through the ``:get()``, ``:put()``, ``:info()``, ``:txn()`` |
| 205 | +methods with the same signature as in the server |
| 206 | +:ref:`config.storage <config_module_api_reference>` API. |
| 207 | + |
| 208 | +The ``config.storage_client`` API has also several specific methods: |
| 209 | +``:is_connected()``, ``:watch()``, ``:reconnect()``, ``:close()``. |
| 210 | + |
| 211 | +Here are some usage examples: |
| 212 | + |
| 213 | +.. code-block:: lua |
| 214 | +
|
| 215 | + -- Connect to a config.storage cluster using the endpoints |
| 216 | + -- configured in the `config.storage` section. |
| 217 | + -- |
| 218 | + -- You can provide endpoints as a Lua table: |
| 219 | + -- |
| 220 | + -- local endpoints = { |
| 221 | + -- { |
| 222 | + -- uri = '127.0.0.1:4401', |
| 223 | + -- login = 'sampleuser', |
| 224 | + -- password = '123456', |
| 225 | + -- } |
| 226 | + -- } |
| 227 | +
|
| 228 | + local endpoints = config:get('config.storage.endpoints') |
| 229 | + local client = config.storage_client.connect(endpoints) |
| 230 | +
|
| 231 | + -- Put a value to the connected client. |
| 232 | + client:put('/v', 'a') |
| 233 | +
|
| 234 | + -- Get all stored values. |
| 235 | + local values = client:get('/') |
| 236 | +
|
| 237 | + -- Clean the storage. |
| 238 | + local response = client:delete('/') |
| 239 | +
|
| 240 | + -- Watch for key changes. |
| 241 | + local log = require('log') |
| 242 | + local w = client:watch('/config/main', function() |
| 243 | + log.info('config has been updated') |
| 244 | + end) |
| 245 | +
|
| 246 | + -- Unregister a watcher. |
| 247 | + w:unregister() |
0 commit comments