Hi Sergei,
I do not think we can use mysql_thread_create() to automatically name the thread.

Performance schema might be 
1) not compiled in , so we can't know the thread names in mysql_thread_create
2) not enabled at runtime, and this is default behavio, we can't know thread names in mysql_thread_create
3)  Even if perfschema is compiled in and enabled, we still need to name threads we're not creating ourselves, this happens e.g with Windows' native threadpool, where we do not have or notification about thread creations.

In all these cases, but especially in 2) we want to have thread names, without perfschema overhead.


On Sat, Jun 8, 2024 at 9:22 PM Sergei Golubchik <serg@mariadb.org> wrote:
Hi, Vladislav,

On Jun 08, Vladislav Vaintroub wrote:
> revision-id: 4ffb583d72f (mariadb-11.0.1-287-g4ffb583d72f)
> parent(s): 7d863d3388d
> author: Vladislav Vaintroub
> committer: Vladislav Vaintroub
> timestamp: 2024-01-20 11:26:21 +0100
> message:
>
> MDEV-32537 Validate my_thread_set_name parameter against performance schema names.
>
> In order to be consistent with PSI force thread name to be the same as
> last part of thread_class_name e.g thread with PSI name
> "thread/sql/main" must be called "main" . Due to Linux restriction on
> thread name length ( 15 chars), full name can't be used.

Does it have to be that way?

I thought that mysql_thread_create() could automatically name the
thread, why would we need to do it manually?

Regards,
Sergei
Chief Architect, MariaDB Server
and security@mariadb.org