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

LP:655186 - disabling innobase_stats_on_metadata disables ANALYZE

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None

      Description

      ha_innobase::analyze(
      /*=================*/
      	THD*		thd,		/*!< in: connection thread handle */
      	HA_CHECK_OPT*	check_opt)	/*!< in: currently ignored */
      {
      	/* Simply call ::info() with all the flags */
      	info(HA_STATUS_TIME | HA_STATUS_CONST | HA_STATUS_VARIABLE);
      
      	return(0);
      }
      

      versus this code in ::info():

      	if (flag & HA_STATUS_TIME) {
      		if (innobase_stats_on_metadata) {
      			/* In sql_show we call with this flag: update
      			then statistics so that they are up-to-date */
      
      			prebuilt->trx->op_info = "updating table statistics";
      
      			dict_update_statistics(ib_table);
      
      			prebuilt->trx->op_info = "returning various info to MySQL";
      		}
      

      The solution is pretty simple, in ::info() do something like the following:

      if (! innobase_stats_on_metadata)
          dict_update_statistics(prebuilt->table);
      

      It does not seem like it was the intention of innobase_stats_on_metadata to also disable ANALYZE

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

              Hide
              ratzpo Rasmus Johansson added a comment -

              Re: disabling innobase_stats_on_metadata disables ANALYZE
              XtraDB already has the following code.

              if (flag & HA_STATUS_TIME) {

              • if (innobase_stats_on_metadata) {
                + if (innobase_stats_on_metadata
                + || thd_sql_command(user_thd) == SQLCOM_ANALYZE
                + ) {
                /* In sql_show we call with this flag: update
                then statistics so that they are up-to-date */

              Why was the bug confirmed??

              Show
              ratzpo Rasmus Johansson added a comment - Re: disabling innobase_stats_on_metadata disables ANALYZE XtraDB already has the following code. if (flag & HA_STATUS_TIME) { if (innobase_stats_on_metadata) { + if (innobase_stats_on_metadata + || thd_sql_command(user_thd) == SQLCOM_ANALYZE + ) { /* In sql_show we call with this flag: update then statistics so that they are up-to-date */ Why was the bug confirmed??
              Hide
              monty Michael Widenius added a comment -

              re: [Bug 655186] [NEW] disabling innobase_stats_on_metadata disables ANALYZE

              Hi!

              >>>>> "Stewart" == Stewart Smith <stewart@flamingspork.com> writes:

              Stewart> Public bug reported:
              Stewart> ha_innobase::analyze(
              Stewart> /=================/
              Stewart> THD* thd, /*!< in: connection thread handle */
              Stewart> HA_CHECK_OPT* check_opt) /*!< in: currently ignored */
              Stewart>

              { Stewart> /* Simply call ::info() with all the flags */ Stewart> info(HA_STATUS_TIME | HA_STATUS_CONST | HA_STATUS_VARIABLE); Stewart> return(0); Stewart> }

              Stewart> versus this code in ::info():

              Stewart> if (flag & HA_STATUS_TIME) {
              Stewart> if (innobase_stats_on_metadata)

              { Stewart> /* In sql_show we call with this flag: update Stewart> then statistics so that they are up-to-date */ Stewart> prebuilt->trx->op_info = "updating table Stewart> statistics"; Stewart> dict_update_statistics(ib_table); Stewart> prebuilt->trx->op_info = "returning various info to MySQL"; Stewart> }

              Stewart> The solution is pretty simple, in ::info() do something like the following:

              Stewart> if (! innobase_stats_on_metadata)
              Stewart> dict_update_statistics(prebuilt->table);

              Stewart> It does not seem like it was the intention of innobase_stats_on_metadata to also disable ANALYZE

              Good catch.

              Vadim, can you add this fix to xtradb?

              Regards,
              Monty

              Show
              monty Michael Widenius added a comment - re: [Bug 655186] [NEW] disabling innobase_stats_on_metadata disables ANALYZE Hi! >>>>> "Stewart" == Stewart Smith <stewart@flamingspork.com> writes: Stewart> Public bug reported: Stewart> ha_innobase::analyze( Stewart> / ================= / Stewart> THD* thd, /*!< in: connection thread handle */ Stewart> HA_CHECK_OPT* check_opt) /*!< in: currently ignored */ Stewart> { Stewart> /* Simply call ::info() with all the flags */ Stewart> info(HA_STATUS_TIME | HA_STATUS_CONST | HA_STATUS_VARIABLE); Stewart> return(0); Stewart> } Stewart> versus this code in ::info(): Stewart> if (flag & HA_STATUS_TIME) { Stewart> if (innobase_stats_on_metadata) { Stewart> /* In sql_show we call with this flag: update Stewart> then statistics so that they are up-to-date */ Stewart> prebuilt->trx->op_info = "updating table Stewart> statistics"; Stewart> dict_update_statistics(ib_table); Stewart> prebuilt->trx->op_info = "returning various info to MySQL"; Stewart> } Stewart> The solution is pretty simple, in ::info() do something like the following: Stewart> if (! innobase_stats_on_metadata) Stewart> dict_update_statistics(prebuilt->table); Stewart> It does not seem like it was the intention of innobase_stats_on_metadata to also disable ANALYZE Good catch. Vadim, can you add this fix to xtradb? Regards, Monty
              Hide
              monty Michael Widenius added a comment -

              [Bug 655186] Re: disabling innobase_stats_on_metadata disables ANALYZE

              Hi!

              >>>>> "Yasufumi" == Yasufumi Kinoshita <yasufumi.kinoshita@percona.com> writes:

              Yasufumi> XtraDB already has the following code.
              Yasufumi> if (flag & HA_STATUS_TIME) {
              Yasufumi> - if (innobase_stats_on_metadata) {
              Yasufumi> + if (innobase_stats_on_metadata
              Yasufumi> + || thd_sql_command(user_thd) == SQLCOM_ANALYZE
              Yasufumi> + ) {
              Yasufumi> /* In sql_show we call with this flag: update
              Yasufumi> then statistics so that they are up-to-date */

              Yasufumi> Why was the bug confirmed??

              I don't think you should depend on the SQLCOM_ANALYZE status; Someone
              may want in the future to call analyze() from other points in the code.

              A better way would be to add an engine specific
              HA_STATUS_INNODB_ANALYZE flag from ha_innobase::analyze() and test
              this in info().

              Regards,
              Monty

              Show
              monty Michael Widenius added a comment - [Bug 655186] Re: disabling innobase_stats_on_metadata disables ANALYZE Hi! >>>>> "Yasufumi" == Yasufumi Kinoshita <yasufumi.kinoshita@percona.com> writes: Yasufumi> XtraDB already has the following code. Yasufumi> if (flag & HA_STATUS_TIME) { Yasufumi> - if (innobase_stats_on_metadata) { Yasufumi> + if (innobase_stats_on_metadata Yasufumi> + || thd_sql_command(user_thd) == SQLCOM_ANALYZE Yasufumi> + ) { Yasufumi> /* In sql_show we call with this flag: update Yasufumi> then statistics so that they are up-to-date */ Yasufumi> Why was the bug confirmed?? I don't think you should depend on the SQLCOM_ANALYZE status; Someone may want in the future to call analyze() from other points in the code. A better way would be to add an engine specific HA_STATUS_INNODB_ANALYZE flag from ha_innobase::analyze() and test this in info(). Regards, Monty
              Hide
              ratzpo Rasmus Johansson added a comment -

              Re: disabling innobase_stats_on_metadata disables ANALYZE
              Monty,

              XtraDB currently is maintained as patch cluster form InnoDB-Plugin by only few person.
              It can be ignored and conflicted in the future InnoDB-Plugin.
              Especially, the first-aid patch for the bug of InnoDB-Plugin should be small and clear to understand later,
              and doesn't need to think future call.

              This bug should be fixed at the main branch of InnoDB at first.
              I will decide after fixing at the main branch when I will meet the conflict through porting the patches to the next version.
              I have limited resource only, I don't want to spent them for dim specification which can be ineffectual in the future.

              Regards,
              Yasufumi

              Show
              ratzpo Rasmus Johansson added a comment - Re: disabling innobase_stats_on_metadata disables ANALYZE Monty, XtraDB currently is maintained as patch cluster form InnoDB-Plugin by only few person. It can be ignored and conflicted in the future InnoDB-Plugin. Especially, the first-aid patch for the bug of InnoDB-Plugin should be small and clear to understand later, and doesn't need to think future call. This bug should be fixed at the main branch of InnoDB at first. I will decide after fixing at the main branch when I will meet the conflict through porting the patches to the next version. I have limited resource only, I don't want to spent them for dim specification which can be ineffectual in the future. Regards, Yasufumi
              Hide
              ratzpo Rasmus Johansson added a comment -

              Launchpad bug id: 655186

              Show
              ratzpo Rasmus Johansson added a comment - Launchpad bug id: 655186
              Hide
              elenst Elena Stepanova added a comment -

              Not sure if the problem still exists in the code, but I don't think it has suddenly become urgent after two years; setting to Minor and removing the upcoming 5.3.10 release from the 'fix' list.

              Show
              elenst Elena Stepanova added a comment - Not sure if the problem still exists in the code, but I don't think it has suddenly become urgent after two years; setting to Minor and removing the upcoming 5.3.10 release from the 'fix' list.
              Hide
              elenst Elena Stepanova added a comment -

              The upstream bug #57252 was fixed in MySQL 5.1 (and merged up) long time ago.

              Show
              elenst Elena Stepanova added a comment - The upstream bug #57252 was fixed in MySQL 5.1 (and merged up) long time ago.
              Hide
              elenst Elena Stepanova added a comment -

              The upstream fix is present in MariaDB 5.1 and higher.

              Show
              elenst Elena Stepanova added a comment - The upstream fix is present in MariaDB 5.1 and higher.

                People

                • Assignee:
                  Unassigned
                  Reporter:
                  stewart Stewart Smith
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  1 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: