1
0
mirror of https://github.com/MariaDB/server.git synced 2026-10-23 18:49:29 +03:00
Files
mariadb/sql
Pekka Lampio 88f91a4bf8 MDEV-39143 follow-up: fix review findings in MySQL JSON replication
Addresses issues found in review of 16ce07df15 (Replicate MySQL binary
JSON to a MariaDB slave), in both the new code and two pieces of
pre-existing core replication code it interacts with. Issue numbers
below refer to the review's own numbering (I001-I039).

Crashes and silent corruption:
 - A truncated or malformed Json_diff vector in a
   PARTIAL_UPDATE_ROWS_EVENT could NULL-deref the slave:
   safe_net_field_length_ll() nulls its cursor on a truncated
   encoding, and nothing checked for that. (I001, I002)
 - The same unchecked-cursor bug existed in the after-image header
   parser, which additionally had no bound on partial_bits
   consumption and did not reject out-of-range value_options. (I005)
 - A diff that MySQL's own applier would REJECT (its path doesn't
   match the slave's document) was silently applied as a no-op
   instead of halting replication - the opposite of MySQL's own
   behavior (ER_COULD_NOT_APPLY_JSON_DIFF). (I004, I025)
 - Corrupt MySQL binary JSON in a diff value was committed as a JSON
   null instead of being detected: Field_mysql_json::val_str() pushes
   an error but returns a non-null empty string on failure, so the
   previous `if (!vtext)` check could never fire. (I003)
 - The same silent-corruption class existed on the full-document
   conversion path for a native-JSON target. (I038)
 - find_row() failing to locate the matched row still read the base
   document from stale record[1] data, and did not record the
   correct stream position on error, risking a parse desync under
   slave_exec_mode=IDEMPOTENT. (I020, I033)

Error reporting:
 - Most failure paths in apply_partial_json_column() returned a bare
   HA_ERR_GENERIC with nothing reported to the DBA, contradicting the
   function's own documented contract. (I024, I026, I027, I031)
 - Fixed messages use my_printf_error() rather than
   rgi->rli->report(): do_exec_row()'s caller unconditionally
   re-derives Last_SQL_Error from thd->is_error() once a row event
   returns an error, overwriting anything rgi->rli->report() had
   already recorded with a generic "Got error NNN from storage
   engine" wrapper - only a message already in the diagnostics area
   survives.
 - check_wrong_column_usage() only checked an UPDATE event's
   before-image bitmap, so an incompatible column visible only in
   the after-image (binlog_row_image=MINIMAL) was silently dropped
   from the write set instead of being reported. (I006)
 - slave.cc's IO-thread statement-end tracking was missing
   PARTIAL_UPDATE_ROWS_EVENT, which could produce a false-positive
   "did not receive an expected Rows-log end-of-statement" error.
   (I008)
 - Documented, but did not fix (needs generic plugin refcounting,
   out of scope here): Type_handler::handler_by_name() releases its
   plugin lock before the caller is done using the returned handler,
   a pre-existing race in the data-type plugin framework. (I039)

Design/consistency:
 - A MySQL JSON source converting to a plain string/blob target was
   always classified as safely widening regardless of actual size;
   it is now classified by the target's real declared capacity like
   any other blob/string conversion, so a document that doesn't fit
   requires slave_type_conversions=ALL_LOSSY instead of silently
   truncating under ALL_NON_LOSSY alone. (I007)
 - apply_partial_json_column() now builds its per-diff JSON function
   Items on a private MEM_ROOT freed per row/column, instead of
   thd->mem_root (the statement-level arena), avoiding unbounded
   growth on a large multi-row UPDATE. (I028)
 - An open-coded bitmap test duplicating the existing
   rpl_bitmap_is_set() helper was replaced with a call to it. (I032)
 - Corrected a comment overstating MySQL JSON -> native JSON
   conversion as lossless; a JSONB OPAQUE temporal/decimal value
   loses its original type tag even though its content survives.
   (I036)
 - Deduplicated the "MYSQL_JSON" plugin-name literal into one
   constant. (I037)

Tests:
 - Switched the existing tests from unconditional INSTALL/UNINSTALL
   SONAME to the repo's have_type_mysql_json.inc convention. (I013)
 - Corrected a test comment that misattributed why the from-the-end
   array-index diff is refused. (I014)
 - Extracted the tests' duplicated binlog-fixture-injection and
   post-replication resync logic into shared include files. (I015)
 - Added tests for the missing-plugin, conversion-length-gating, and
   corrupt-diff-vector error paths above. (I016)

Assisted-by: Claude AI
2026-10-16 15:38:55 +03:00
..
2026-06-16 12:24:32 +02:00
2026-06-15 16:53:03 +02:00
2025-10-25 00:19:11 +07:00
…
2026-02-16 21:55:18 +01:00
2025-07-28 21:29:29 +02:00
2024-11-05 14:00:48 -08:00
2025-09-29 18:25:09 +03:00
…
2025-03-14 12:08:56 +04:00
2026-02-16 21:55:18 +01:00
2025-03-14 12:08:56 +04:00
…
2024-12-02 11:35:34 +02:00
2024-12-02 17:51:17 +02:00
2026-01-31 14:08:54 +01:00
2024-10-30 15:11:17 +01:00
…
2026-01-31 14:08:54 +01:00
2026-06-29 07:41:06 +03:00
2024-12-02 11:35:34 +02:00
2026-05-26 21:15:58 +02:00
2026-03-24 09:49:17 +02:00
2026-03-24 09:49:17 +02:00
…
…
2024-11-08 07:17:00 +01:00
2026-05-26 21:15:58 +02:00
2026-06-15 16:53:03 +02:00
2026-05-26 21:15:58 +02:00
2026-05-26 21:15:58 +02:00
2026-05-26 21:15:58 +02:00
2024-11-29 13:43:17 +02:00
…
…
2026-05-26 21:15:58 +02:00
2026-03-27 14:15:54 +01:00
2024-12-05 10:11:58 +01:00
2026-06-29 07:40:04 +03:00
2026-02-03 14:53:15 +01:00
2026-06-29 07:40:04 +03:00
2026-05-26 21:15:58 +02:00
2026-02-03 14:53:15 +01:00
2026-02-03 14:53:15 +01:00
2026-05-26 21:15:58 +02:00
2026-02-03 14:53:15 +01:00
2026-06-23 12:52:39 +02:00
2026-06-29 07:41:06 +03:00
2026-03-24 09:49:17 +02:00
2026-01-31 14:08:54 +01:00
2026-04-01 15:03:59 +03:00
2026-04-02 09:15:17 +03:00
2026-06-16 12:24:32 +02:00
2026-06-16 12:24:32 +02:00
2026-01-08 12:02:45 +01:00
2026-05-08 08:11:03 +02:00
2024-07-08 22:40:16 +02:00
2026-05-26 21:15:58 +02:00
2026-06-16 12:24:32 +02:00
…
2026-06-16 12:24:32 +02:00
2026-05-26 21:15:58 +02:00
…
2025-03-14 12:08:56 +04:00
2026-05-05 13:14:42 +03:00
…
2024-10-03 15:59:20 +10:00
…
2025-03-14 12:08:56 +04:00
2026-05-26 21:15:58 +02:00
2026-05-26 21:15:58 +02:00
2026-06-29 07:41:06 +03:00
2026-05-26 21:15:58 +02:00
2025-04-02 14:07:01 +03:00
2026-05-26 21:15:58 +02:00
2026-02-03 14:53:15 +01:00
2026-05-26 21:15:58 +02:00
2026-04-02 09:15:17 +03:00
2026-02-03 14:53:15 +01:00
2026-05-08 08:00:01 +02:00
2026-03-27 14:15:54 +01:00
2026-01-31 14:08:54 +01:00
2026-05-26 21:15:58 +02:00
2026-02-03 14:53:15 +01:00
2025-09-29 18:25:09 +03:00
2024-07-22 15:14:50 +02:00
2026-05-26 21:15:58 +02:00
2026-05-26 21:15:58 +02:00
2026-02-07 22:06:40 +01:00
2026-05-26 21:15:58 +02:00
2026-06-16 12:24:32 +02:00
2025-07-31 20:55:47 +02:00
2026-02-07 22:06:40 +01:00
2026-06-16 12:24:32 +02:00
2026-06-15 16:53:03 +02:00
2026-06-15 16:53:03 +02:00
2025-03-14 12:08:56 +04:00
2026-04-02 09:15:17 +03:00
2026-05-26 21:15:58 +02:00
2026-05-26 21:15:58 +02:00
2026-02-06 17:46:50 +01:00
2025-11-04 12:39:27 +01:00
2026-06-16 12:24:32 +02:00
2026-06-16 12:24:32 +02:00
2026-05-26 21:15:58 +02:00
2026-06-16 12:24:32 +02:00
2026-02-06 17:46:51 +01:00
2026-06-29 07:40:04 +03:00
2026-01-08 12:02:45 +01:00
2025-09-04 18:08:39 +03:00
2026-05-26 21:15:58 +02:00
2026-02-16 21:55:18 +01:00
2026-05-26 21:15:58 +02:00
2026-05-26 21:15:58 +02:00
2026-06-15 15:15:10 +02:00
2026-06-15 15:15:10 +02:00
2026-01-08 21:41:40 +01:00
2026-05-26 21:15:58 +02:00
2026-05-26 21:15:58 +02:00
2026-04-02 09:15:17 +03:00
2026-05-26 21:15:58 +02:00
2026-01-31 14:08:54 +01:00
2026-01-05 20:34:44 +01:00
2026-06-24 12:27:13 +02:00
2026-03-24 09:49:17 +02:00
2026-06-29 07:40:04 +03:00
2026-01-08 12:02:45 +01:00
2026-05-26 21:15:58 +02:00
2026-02-06 17:46:51 +01:00
2026-03-17 18:57:42 +01:00
2026-06-29 07:40:04 +03:00
…
2026-02-06 17:46:51 +01:00
2026-02-06 17:46:51 +01:00
2026-04-02 09:15:17 +03:00
2025-09-29 18:25:09 +03:00
2025-08-04 12:05:53 +02:00
2024-12-02 17:51:17 +02:00
2026-05-26 21:15:58 +02:00
2025-09-19 12:31:14 +03:00
2026-06-16 12:24:32 +02:00
2026-05-26 21:15:58 +02:00
2025-03-14 12:08:56 +04:00
2026-05-26 21:15:58 +02:00
2024-07-03 12:45:30 +02:00
2026-06-15 16:53:03 +02:00
2026-04-17 09:31:38 +10:00
2026-05-26 21:15:58 +02:00
2025-01-09 09:41:38 +02:00
2026-05-26 21:15:58 +02:00
2024-12-02 17:51:17 +02:00
2026-02-03 14:53:15 +01:00
2026-03-27 14:15:54 +01:00
2026-06-29 07:41:06 +03:00
2026-06-16 12:24:32 +02:00
2026-05-26 21:15:58 +02:00
2026-05-26 21:15:58 +02:00
2026-05-26 21:15:58 +02:00
2026-03-24 09:49:17 +02:00
2026-05-26 21:15:58 +02:00
2026-04-01 10:49:05 +03:00
2026-05-26 21:15:58 +02:00
2026-02-07 22:12:32 +01:00
2025-04-29 11:18:00 +10:00
2026-05-26 21:15:58 +02:00
…
2026-05-22 09:52:05 +02:00
2026-05-22 09:52:05 +02:00
2026-06-16 12:24:32 +02:00
2025-03-14 12:08:56 +04:00
2024-12-02 17:51:17 +02:00
2026-05-26 21:15:58 +02:00
2026-05-26 21:15:58 +02:00
2026-05-26 21:15:58 +02:00
2026-06-15 16:53:03 +02:00
2026-06-29 07:41:06 +03:00
2026-06-23 12:52:39 +02:00
2026-05-26 21:15:58 +02:00
2026-06-24 12:27:13 +02:00
2026-05-26 21:15:58 +02:00
2025-04-29 11:18:00 +10:00
2026-03-24 09:49:17 +02:00
2025-09-04 18:08:39 +03:00
2025-03-14 12:08:56 +04:00
2026-05-22 09:52:05 +02:00
2024-12-02 17:51:17 +02:00
2024-12-02 11:35:34 +02:00
2025-03-14 12:08:56 +04:00
2026-06-16 12:24:32 +02:00
2025-11-28 12:56:27 +02:00
2026-06-15 16:53:03 +02:00
2026-05-26 21:15:58 +02:00
2026-06-21 15:32:20 +02:00
2026-06-15 16:53:03 +02:00
2026-04-02 09:15:17 +03:00
2024-10-03 13:24:43 +03:00
2024-09-09 13:50:38 +03:00
2026-06-24 12:27:13 +02:00
2026-02-07 22:12:32 +01:00
2026-06-23 12:52:39 +02:00
2026-06-23 12:52:39 +02:00
2026-06-24 12:27:13 +02:00
2026-04-01 10:49:05 +03:00
2025-07-31 20:55:47 +02:00