Bug #101395 call "global_thread_list_begin()" always return "end"
Submitted: 30 Oct 2020 8:31 Modified: 10 Nov 2020 7:40
Reporter: zhang CJay Email Updates:
Status: Unsupported Impact on me:
None 
Category:MySQL Server: Embedded Library ( libmysqld ) Severity:S3 (Non-critical)
Version:5.6.30 OS:Windows (Win10)
Assigned to: CPU Architecture:Any

[30 Oct 2020 8:31] zhang CJay
Description:
I build MySQL V5.3.60 source code, and link the mysqld.lib, strings.lib in my code, when I call the function "get_thread_count()", it returns 3, but I want to get the iterator by calling "global_thread_list_begin()", it returns "end" and not equal the result returned by calling "global_thread_list_end()". When I try to get the content of the iterator, it is "NULL".

How to repeat:
You can link the static library and call the function "global_thread_list_begin()", check the return result.
[30 Oct 2020 12:59] MySQL Verification Team
Hi Mr. CJay,

Thank you for your bug report.

Our embedded library works 100 % the same as our server, provided you have built it correctly , linked it correctly and used it correctly. Our Reference Manual contains all the info on how the embedded library should be initialised and how it should be properly built. Hence, make sure that you have done your initialisations correctly.

Also, compare your results with embedded library with those of 5.6.30 server.

We shall wait on your feedback.
[6 Nov 2020 1:42] zhang CJay
Thanks for your reply.
I test the code in VS2019.
I can get a thread_iterator object by calling "global_thread_list_begin()", we know the underlying implementation of "set" uses rb_tree, so the iterator returned by "global_thread_list_begin()" should point to a tree node, and should contains these properties:
    _Nodeptr _Left; // left subtree, or smallest element if head
    _Nodeptr _Parent; // parent, or root of tree if head
    _Nodeptr _Right; // right subtree, or largest element if head
    char _Color; // _Red or _Black, _Black if head
    char _Isnil; // true only if head (also nil) node; TRANSITION, should be 
    bool value_type _Myval; // the stored value, unused if head
Now I want to get the content of the node by calling operator*(), it returns the "_Myval" property, but the value is NULL, in fact, it is not null.

Then I want to traverse the set though the iterator by calling "operator++()", it will use "_Isnil" to check if the node is a leaf node, I found if a node is a leaf node, the "_Isnil" is 0, and if not, the "_Isnil" is not 0, this is just the opposite of using this property in the VC library file "_Tree_unchecked_const_iterator", the result is that it cannot be traversed as expected.
[6 Nov 2020 12:56] MySQL Verification Team
Hi Mr. CJay,

Thank you for your feedback.

However, this is not a version which will receive bug fixes. Version 5.6 is reaching EOL relatively soon, so it can receive only security bugs. Also, later version do not support thread iterator. Needless to say, what you report is not a security bug.

Next, it is also evident that you have not done all initialisations that were necessary.

Unsupported.
[9 Nov 2020 8:27] zhang CJay
Yes, I checked the source code of version 5.7 and cannot find the interface. But if I want to get all the client connections, is there any other way to get them?
Thanks.
[9 Nov 2020 12:55] MySQL Verification Team
HI,

We are afraid that embedded library is deprecated and hence not available any more.

If you are looking for browsing through server's threads, you will have to write a plugin. All the documentation on plugins is found in our Reference Manual.
[10 Nov 2020 7:40] zhang CJay
Thanks for your help.
[10 Nov 2020 12:18] MySQL Verification Team
Hi Mr. CJay,

You are welcome .....