[MXS-1629] ThreadId conflicts Created: 2018-01-26  Updated: 2022-09-08  Resolved: 2022-09-08

Status: Closed
Project: MariaDB MaxScale
Component/s: N/A
Affects Version/s: None
Fix Version/s: N/A

Type: New Feature Priority: Major
Reporter: dapeng huang Assignee: Johan Wikman
Resolution: Won't Do Votes: 0
Labels: None

Attachments: JPEG File ddd.jpg    
Sprint: MXS-SPRINT-51

 Description   

32bits threadid is not big enough, If client open/close connection rapidly, potentially there will be conflicts;
In our product env, we do see many clients create connections more than 1000 per second,
the threadid will overflow after 49.71 (4294967296(32bit) / 1000 / 86400 ) days.
So we need make threadid unique;



 Comments   
Comment by Johan Wikman [ 2018-01-26 ]

dapeng From you comment at https://github.com/mariadb-corporation/MaxScale/pull/160

our proposal is:
 
divide session id into two part,
 
 |31 - 24| 23 - 0|
|-------|------|
|nodeid | session id|
 
set this session id back to server
 
so if worker thread has a session id pool, another bits will be consumed

I don't fully understand the proposal. What would nodeid denote?

Comment by dapeng huang [ 2018-01-26 ]

the scenario is deploy multi mxs nodes behind a load balancer, client use single vip,
there are big chance of encountering session id conflicts;

so we can add a prefix to session id, nodeid is proxy node (mxs)'s id, with it , we can divide session id into different space,there will be no confilcts;

but there still have another problem, `kill connection` may issued from different connection which may different from the node of to be killed connection, so there is no mapping data for that to be killed connection;
So we need a way to set the sessionid generated by mxs back to server, then we not need do mapping anymore;

Comment by dapeng huang [ 2018-01-26 ]

maybe we can divid it into three part

31-24 23-13 13-0
nodeid threadid sessionid

8 bits nodeid: max 255 nodes per cluster;

10 bits threads: max 1024 threads per node

14 bit sessionid :max 16384 per thread;

Comment by Johan Wikman [ 2018-01-26 ]

Ok, so nodeid would then have to be provided via some configuration item in the MaxScale configuration file?

10 bits for the threadid might be a bit excessive as it makes no sense to use more worker threads than there are real cores in the computer. Perhaps 8 bits would be enough.

With the MaxScale worker thread id in the connection id, it is easy to move the handling of kill connection to the right thread.

Comment by Johan Wikman [ 2018-01-26 ]

If the nodeid is different, then it doesn't work.

Comment by dapeng huang [ 2018-01-26 ]

Sorry , my english is not so well, let me explain with this diagram:

by this way we can make session id global unique, so we don't need translate client session id to backend session id;

Currently in our internal version mysql, we have implicated a way to set "thread id" to server, maybe mariadb can do the same thing

Comment by Johan Wikman [ 2018-01-29 ]

Even if MaxScale were to reuse ids to ensure that the thread id cannot be overflow, that's not that useful unless the server does the same. So indeed, if MaxScale were able to specify the thread id to be used, it would be good.

Comment by markus makela [ 2020-08-27 ]

Changing to a new feature as this is expected behavior.

Comment by markus makela [ 2022-04-24 ]

An interesting approach to this would be for MaxScale to inject some connection attributes to the outbound connections that could be used to identify which session in MaxScale the connection relates to. This could also include the hostname from which the connection is created.

Generated at Thu Feb 08 04:08:13 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.