Skip to content

Conversation

mariadb-RexJohnston
Copy link
Member

@@new_mode is a set of flags to control introduced features. Flags are by default off. Setting a flag in @@new_mode will introduce a new different server behaviour and/or set of features.

  • The Jira issue number for this PR is: MDEV-37784

Description

@@new_mode is a set of flags to control introduced features.
Flags are by default off. Setting a flag in @@new_mode will introduce
a new different server behaviour and/or set of features.

Release Notes

New global and session variable new_mode.
This needs updating.
https://mariadb.com/docs/server/server-management/variables-and-modes/server-system-variables

How can this PR be tested?

TODO: modify the automated test suite to verify that the PR causes MariaDB to behave as intended.
Consult the documentation on "Writing good test cases".

If the changes are not amenable to automated testing, please explain why not and carefully describe how to test manually.

Basing the PR against the correct MariaDB version

  • This is a new feature or a refactoring, and the PR is based against the main branch.
  • This is a bug fix, and the PR is based against the earliest maintained branch in which the bug can be reproduced.

PR quality check

  • I checked the CODING_STANDARDS.md file and my PR conforms to this where appropriate.
  • For any trivial modifications to the PR, I am ok with the reviewer making the changes themselves.

@svoj svoj added External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements. MariaDB Corporation and removed External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements. labels Oct 2, 2025
net-read-timeout 30
net-retry-count 10
net-write-timeout 60
new-mode NOW_DEFAULT
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's NOW_DEFAULT ? I think the intent was that by default the variable would be empty.

Copy link
Member Author

@mariadb-RexJohnston mariadb-RexJohnston Oct 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOW_DEFAULT is a placeholder for features that were opt-in in previous versions, but are now default.
So for example, we introduce [NEW_MODE_]FIX_DISK_TMPTABLE_COSTS as a flag disabled by default.

#define NEW_MODE_FIX_DISK_TMPTABLE_COSTS (1 << 1)

when we wish to make this default, all we need to do is..

#define NEW_MODE_FIX_DISK_TMPTABLE_COSTS (1 << 0)

We wont need to (though we should) change the actual code itself.

sql/sys_vars.cc Outdated

static Sys_var_set Sys_new_behavior(
"new_mode",
"Used to introduce new behavior to new MariaDB versions",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can introduce new behavior to new versions just fine.
@@new_mode's purpose is to allow new behaviors to be added to OLD versions. Where we have to have them switchable and disabled by default.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll change the wording.

NUMERIC_MIN_VALUE NULL
NUMERIC_MAX_VALUE NULL
NUMERIC_BLOCK_SIZE NULL
ENUM_VALUE_LIST NOW_DEFAULT,FIX_DISK_TMPTABLE_COSTS,FIX_SEMIJOIN_DUPS_WEEDOUT_CHECK,TEST_WARNING1,TEST_WARNING2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it feasible to get rid of TEST_WARNINGs here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want to see NOW_DEFAULT either, since it is pointless setting this. Looking...

Copy link
Member Author

@mariadb-RexJohnston mariadb-RexJohnston Oct 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can introduce a set of "hidden" values in Sys_var_typelib, default empty.

@mariadb-RexJohnston mariadb-RexJohnston force-pushed the 11.8-MDEV-37784 branch 2 times, most recently from d54ab4f to df8f699 Compare October 2, 2025 22:59
@@new_mode is a set of flags to control introduced features.
Flags are by default off.  Setting a flag in @@new_mode will introduce
a new different server behaviour and/or set of features.

We also introduce a new option 'hidden_values' into some system variable
types to hide options that we do not wish to show as options.
@spetrunia
Copy link
Member

Ouch, I've made a mistake: pushed another fix into this PR branch, 11.8-MDEV-37784. Sorry for any inconvenience.

@spetrunia
Copy link
Member

So, mysqld --help --verbose output still mentions hidden names:

                      versions. Any combination of: NOW_DEFAULT, 
                      FIX_DISK_TMPTABLE_COSTS, FIX_SEMIJOIN_DUPS_WEEDOUT_CHECK,
                      TEST_WARNING1, TEST_WARNING2, or ALL to set all
                      combinations

@spetrunia
Copy link
Member

MariaDB [test]> set @@new_mode='ALL';
Query OK, 0 rows affected, 2 warnings (0.001 sec)

MariaDB [test]> show warnings;
+---------+------+----------------------------------------+
| Level   | Code | Message                                |
+---------+------+----------------------------------------+
| Warning | 4209 | 'TEST_WARNING1' is default and ignored |
| Warning | 4209 | 'TEST_WARNING2' is default and ignored |
+---------+------+----------------------------------------+
2 rows in set (0.000 sec)

I would expect the warnings not to be there...

@dr-m
Copy link
Contributor

dr-m commented Oct 3, 2025

Has the name new_mode been carefully thought through? It could get old quickly. I’m grateful that more than 20 years ago, someone opposed my lazy proposal of ROW_FORMAT=NEW and MySQL 5.0.3 got ROW_FORMAT=COMPACT instead. The ROW_FORMAT=NEW would have gotten embarrassing when ROW_FORMAT=DYNAMIC was reused by InnoDB some years later.

Possible replacements of the word ‘new’ would include ‘extended’ or ‘backported’. Perhaps some native English speakers can think of even better alternatives?

@spetrunia
Copy link
Member

@dr-m , well, old_mode is already there.
This is different from row_format=new, which won't be new in a few years.
new_mode is a set of flags which will appear and eventually disappear.

- Don't print hidden values in mysqld --help output.
- Better function names and formatting.
- Make get_options() use the same logic as check_new_mode_value() does.
- More renames
@spetrunia
Copy link
Member

.. pushed 3 commits with obvious fixes.
One thing that's still not clear to me: @mariadb-RexJohnston , what is NOW_DEFAULT and why is it needed?

@mariadb-RexJohnston
Copy link
Member Author

If we are to be able to change the behaviour by changing our flags and leaving the rest of the codebase alone when a feature transitions from 'beta' to 'default' (which i think will be an important property), we need the evaluation of

thd->variables.new_mode & NEW_MODE_FEATURE_BECOMING_DEFAULT

to be non-zero, so some bit in thd->variables.new_mode needs to be non-zero.
NOW_DEFAULT is that bit.
We redefine NEW_MODE_FEATURE_BECOMING_DEFAULT from whatever bit it used to be, to the same as the default bit and the feature is now by default, enabled.

@spetrunia
Copy link
Member

That's internal reason. Let's look at this from the user point of view.
From the user point of view, NOW_DEFAULT doesn't seem to make much sense.

If we are to be able to change the behaviour by changing our flags and leaving the rest of the codebase alone when a feature transitions from 'beta' to 'default' (which i think will be an important property), we need the evaluation of

thd->variables.new_mode & NEW_MODE_FEATURE_BECOMING_DEFAULT

Two points:
A. I actually expect us to remove the logic providing the old behavior.
The only remainder would be an entry in new_mode_all_names, so if somebody upgrades but doesn't edit their my.cnf, they do not get errors.

What if for some reason we want the logic in the code to remain?
I think this can also be achieved. In the patch for MDEV-37732, I already have the check in this form

    if (optimizer_new_mode(thd, NEW_MODE_FIX_SEMIJOIN_DUPS_WEEDOUT_CHECK) &&

optimizer_new_mode at the moment is

inline bool optimizer_new_mode(const THD *thd, ulonglong mode_flag)
{            
  return (thd->variables.new_behavior & mode_flag);
}

We could introduce

#define NEW_MODE_VALUE_FOR_ENABLED_ALWAYS  number

and then eventually we would do

#define NEW_MODE_FIX_SEMIJOIN_DUPS_WEEDOUT_CHECK  NEW_MODE_VALUE_FOR_ENABLED_ALWAYS

and then optimizier_new_mode() would return true for NEW_MODE_VALUE_FOR_ENABLED_ALWAYS regardless of thd->variables.new_behavior setting.

Comment on lines 346 to 351
array_elements(innodb_linux_aio_names) - 1,
"innodb_linux_aio_typelib",
innodb_linux_aio_names,
NULL
NULL, NULL
};
#endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this change about? Why is it needed? There is no mention of this in the commit message.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TYPELIB is changed, so every TYPELIB static initializer has to be too. I'll change this place to use CREATE_TYPELIB_FOR() macro (like few lines above)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

5 participants