mirror of
https://github.com/scylladb/scylladb.git
synced 2026-05-28 18:50:53 +00:00
Previously batch statement result set included rows for only those updates which have a prefetch data present (i.e. there was an "old" (pre-existing) row for a key). Also, these rows were sorted not in the order in which statements appear in the batch, but in the order of updated clustering keys. If we have a batch which updates a few non-existent keys, then it's impossible to figure out which update inserted a new key by looking at the query response. Not only because the responses may not correspond to the order of statements in the batch, but even some rows may not show up in the result set at all. Please see #7113 on Github for detailed description of the problem: https://github.com/scylladb/scylla/issues/7113 The patch set proposes the following fix: For conditional batch statements the result set now always includes a row for each LWT statement, in the same order in which individual statements appear in the batch. This way we can always tell which update did actually insert a new key or update the existing one. Technically, the following changes were made: * `update_parameters::prefetch_data::row::is_in_cas_result_set` member removed as well as the supporting code in `cas_request::applies_to` which iterated through cas updates and marked individual `prefetch_data` rows as "need to be in cas result set". * `cas_request::applies_to` substantially simplified since it doesn't do anything more than checking `stmt.applies_to()` in short-circuiting manner. * `modification_statement::build_cas_result_set` method moved to `cas_request`. This allows to easily iterate through individual `cas_row_update` instances and preserve the order of the rows in the result set. * A little helper `cas_request::find_old_row` is introduced to find a row in `prefetch_data` based on the (pk, ck) combination obtained from the current `cas_request` and a given `cas_row_update`. * A few tests for the issue #7113 are written, other lwt-batch-related tests adjusted accordingly.