Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-26724

Endless loop in json_escape_to_string upon collecting JSON histograms with empty string in a column

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: N/A
    • Fix Version/s: 10.7.1
    • Component/s: Optimizer
    • Labels:
      None

      Description

      CREATE OR REPLACE TABLE t (f VARCHAR(8));
      INSERT INTO t VALUES ('a'),(''),('b');
      SET histogram_type=JSON_HB;
      ANALYZE TABLE t PERSISTENT FOR ALL;
       
      # Cleanup
      DROP TABLE t;
      

      The server hangs upon ANALYZE, or rather falls into a loop with 100% CPU and 3G+ memory consumption somewhere here:

      preview-10.7-MDEV-26519-json-histograms 656dff975

      Thread 9 (Thread 0x7f61088ef700 (LWP 62824)):
      #0  0x0000558913514881 in json_escape (str_cs=0x558914a79a40 <my_charset_utf8mb4_bin>, str=0x7f608412a6da "a", str_end=0x7f608412a6da "a", json_cs=0x558914a79a40 <my_charset_utf8mb4_bin>, json=0x7f5fbefff098 "", json_end=0x7f607ffff090 "h4z\025") at /data/src/preview-10.7-MDEV-26519-json-histograms/strings/json_lib.c:1618
      #1  0x0000558912199e24 in json_escape_to_string (val=0x7f608412a6da "a", val_len=0, out=0x7f61088ecd10) at /data/src/preview-10.7-MDEV-26519-json-histograms/sql/opt_histogram_json.cc:72
      #2  0x000055891219d92f in Histogram_json_builder::append_column_value (this=0x7f60840aa120, elem=0x7f60840618a0) at /data/src/preview-10.7-MDEV-26519-json-histograms/sql/opt_histogram_json.cc:203
      #3  0x000055891219d776 in Histogram_json_builder::start_bucket (this=0x7f60840aa120, elem=0x7f60840618a0, cnt=1) at /data/src/preview-10.7-MDEV-26519-json-histograms/sql/opt_histogram_json.cc:182
      #4  0x000055891219dce9 in Histogram_json_builder::next (this=0x7f60840aa120, elem=0x7f60840618a0, elem_cnt=1) at /data/src/preview-10.7-MDEV-26519-json-histograms/sql/opt_histogram_json.cc:261
      #5  0x0000558911f4a56c in histogram_build_walk (elem=0x7f60840618a0, elem_cnt=1, arg=0x7f60840aa120) at /data/src/preview-10.7-MDEV-26519-json-histograms/sql/sql_statistics.cc:1672
      #6  0x000055891345fd78 in tree_walk_left_root_right (tree=0x7f6084015ca8, element=0x7f6084061888, action=0x558911f4a51d <histogram_build_walk(void*, element_count, void*)>, argument=0x7f60840aa120) at /data/src/preview-10.7-MDEV-26519-json-histograms/mysys/tree.c:590
      #7  0x000055891345fcef in tree_walk_left_root_right (tree=0x7f6084015ca8, element=0x7f6084061860, action=0x558911f4a51d <histogram_build_walk(void*, element_count, void*)>, argument=0x7f60840aa120) at /data/src/preview-10.7-MDEV-26519-json-histograms/mysys/tree.c:588
      #8  0x000055891345fc28 in tree_walk (tree=0x7f6084015ca8, action=0x558911f4a51d <histogram_build_walk(void*, element_count, void*)>, argument=0x7f60840aa120, visit=left_root_right) at /data/src/preview-10.7-MDEV-26519-json-histograms/mysys/tree.c:576
      #9  0x000055891206e6b0 in Unique::walk (this=0x7f6084015b00, table=0x7f60841ae108, action=0x558911f4a51d <histogram_build_walk(void*, element_count, void*)>, walk_action_arg=0x7f60840aa120) at /data/src/preview-10.7-MDEV-26519-json-histograms/sql/uniques.cc:654
      #10 0x0000558911f5a3d0 in Count_distinct_field::walk_tree_with_histogram (this=0x7f6084015ad0, rows=3) at /data/src/preview-10.7-MDEV-26519-json-histograms/sql/sql_statistics.cc:1780
      #11 0x0000558911f5b823 in Column_statistics_collected::finish (this=0x7f608412a848, mem_root=0x7f60841ae3a0, rows=3, sample_fraction=1) at /data/src/preview-10.7-MDEV-26519-json-histograms/sql/sql_statistics.cc:2500
      #12 0x0000558911f4c7fa in collect_statistics_for_table (thd=0x7f6084000db8, table=0x7f60841ae108) at /data/src/preview-10.7-MDEV-26519-json-histograms/sql/sql_statistics.cc:2803
      #13 0x000055891210da64 in mysql_admin_table (thd=0x7f6084000db8, tables=0x7f6084015130, check_opt=0x7f60840063a8, operator_name=0x558913f0a4a0 <msg_analyze>, lock_type=TL_READ_NO_INSERT, org_open_for_modify=true, repair_table_use_frm=false, extra_open_options=0, prepare_func=0x0, operator_func=(int (handler::*)(class handler * const, class THD *, HA_CHECK_OPT *)) 0x55891248cb82 <handler::ha_analyze(THD*, st_ha_check_opt*)>, view_operator_func=0x0, is_cmd_replicated=true) at /data/src/preview-10.7-MDEV-26519-json-histograms/sql/sql_admin.cc:1042
      #14 0x000055891211166d in Sql_cmd_analyze_table::execute (this=0x7f6084015818, thd=0x7f6084000db8) at /data/src/preview-10.7-MDEV-26519-json-histograms/sql/sql_admin.cc:1517
      #15 0x0000558911d93fb7 in mysql_execute_command (thd=0x7f6084000db8, is_called_from_prepared_stmt=false) at /data/src/preview-10.7-MDEV-26519-json-histograms/sql/sql_parse.cc:5989
      #16 0x0000558911d9fe25 in mysql_parse (thd=0x7f6084000db8, rawbuf=0x7f6084015050 "ANALYZE TABLE t PERSISTENT FOR ALL", length=34, parser_state=0x7f61088ee480) at /data/src/preview-10.7-MDEV-26519-json-histograms/sql/sql_parse.cc:8029
      #17 0x0000558911d760ed in dispatch_command (command=COM_QUERY, thd=0x7f6084000db8, packet=0x7f608412dfc9 "", packet_length=34, blocking=true) at /data/src/preview-10.7-MDEV-26519-json-histograms/sql/sql_parse.cc:1894
      #18 0x0000558911d73183 in do_command (thd=0x7f6084000db8, blocking=true) at /data/src/preview-10.7-MDEV-26519-json-histograms/sql/sql_parse.cc:1402
      #19 0x00005589120dc1c1 in do_handle_one_connection (connect=0x558917cd3998, put_in_cache=true) at /data/src/preview-10.7-MDEV-26519-json-histograms/sql/sql_connect.cc:1418
      #20 0x00005589120db989 in handle_one_connection (arg=0x558917cd22c8) at /data/src/preview-10.7-MDEV-26519-json-histograms/sql/sql_connect.cc:1312
      #21 0x00005589129bf779 in pfs_spawn_thread (arg=0x558917cd34e8) at /data/src/preview-10.7-MDEV-26519-json-histograms/storage/perfschema/pfs.cc:2201
      #22 0x00007f611319f609 in start_thread (arg=<optimized out>) at pthread_create.c:477
      #23 0x00007f6112d72293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
      

      Probably caused by MDEV-26711 patch, although I didn't check.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              psergei Sergei Petrunia
              Reporter:
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Git Integration