Re: Request for submitting a PECL extension which uses mysqlnd pluginAPIand enables redirection functionality for MySQL servers

From: Date: Mon, 23 Sep 2019 17:11:59 +0000
Subject: Re: Request for submitting a PECL extension which uses mysqlnd pluginAPIand enables redirection functionality for MySQL servers
References: 1 2 3 4 5  Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-16235@lists.php.net to get a copy of this message
Hi Qianqian Bu, <https://github.com/microsoft/mysqlnd_azure> looks fine so far, but there is no actual code yet; I only can see .gitignore, LICENSE.txt and README.md. Best regards, Christoph On 20.09.2019 at 08:37, Qianqian Bu wrote: > Hi Christoph, > > It has been a while, and we have a public repo > https://github.com/microsoft/mysqlnd_azure available now for the > extension source code. I've created the package.xml file and add a brief Readme.txt under > folder mysqlnd_azure. Could you help review the code again if any problem? The user name in the > package.xml is invalid since I just submitted the php user account form and request is not finished > yet. Thanks. > > Best Regards, > Qianqian Bu > > > -----Original > Message----------------------------------------------------------------------------------------------------------------- > From: Christoph M. Becker <cmbecker69@gmx.de> > Sent: Monday, August 12, 2019 4:56 PM > To: Qianqian Bu <Qianqian.Bu@microsoft.com>; pecl-dev@lists.php.net > Cc: Hong Wang (R&D) <howang@microsoft.com>; Hang Zhang <haz@microsoft.com>; > Xiangyu Hu <Xiangyu.Hu@microsoft.com>; Shuode Li <shuodl@microsoft.com> > Subject: Re: Request for submitting a PECL extension which uses mysqlnd pluginAPIand enables > redirection functionality for MySQL servers > > Hi Qianqian Bu! > > On 12.08.2019 at 05:03, Qianqian Bu via pecl-dev wrote: > >> Hi Christoph, >> >> Thanks so much for your checking and response. For the code repo, we currently have a >> private github repo which is currently on-going legal review and will be publicly accessible in near >> future. I think it will be suitable to hold the code, I'll update with you when it is ready. >> And I'll try to generate package.xml later. There is a change for the extension implementation, >> that is we decide to rename the extension with name from mysqlnd_rd to mysqlnd_azure, may I ask does >> the name sound good to you? > > I have no objections regarding the name. > > Regards, > Christoph > >> Thanks & Best Regards, >> Qianqian Bu >> >> -----Original >> Message--------------------------------------------------------------- >> --------------------------------- >> From: Christoph M. Becker <cmbecker69@gmx.de> >> Sent: Wednesday, August 7, 2019 5:23 PM >> To: Qianqian Bu <Qianqian.Bu@microsoft.com>; pecl-dev@lists.php.net >> Cc: Hong Wang (R&D) <howang@microsoft.com>; Hang Zhang >> <haz@microsoft.com>; Xiangyu Hu <Xiangyu.Hu@microsoft.com>; Shuode Li >> <shuodl@microsoft.com> >> Subject: Re: Request for submitting a PECL extension which uses >> mysqlnd plugin APIand enables redirection functionality for MySQL >> servers >> >> Hi! >> >> On 07.08.2019 at 10:03, Qianqian Bu via pecl-dev wrote: >> >>> Dear Madam/Sir, >>> >>> My name is Qianqian Bu, I'm from Microsoft company and recently work on a project >>> which enables redirection functionality for MySQL servers using PHP mysqlnd driver. The >>> functionality has been implemented as a PHP extension using mysqlnd plugin API, and I'd like to >>> request submitting it to PECL website. >>> >>> There is a document >>> https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fjira.mariadb.org%2Fbrowse%2FMDEV-15935&amp;data=02%7C01%7CQianqian.Bu%40microsoft.com%7C0f78a037b5ea42ccf72c08d71f02f1a5%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637011969848063890&amp;sdata=Q6jxna3Ix9n2iJoEEBG2gljfgroOXIav9eT9s4l%2F%2Fyw%3D&amp;reserved=0 >>> for MariaDB Connector J for the same purpose which you may use as a reference. The document gives >>> the purpose and initial approach. The final implementation takes use of the message field of OK >>> packet, server fills the message field with redirection information, then driver side needs extract >>> the information and use it to establish a new connection. There is a ongoing pull request >>> https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FMariaDB%2Fmariadb-connector-j%2Fpull%2F134&amp;data=02%7C01%7CQianqian.Bu%40microsoft.com%7C0f78a037b5ea42ccf72c08d71f02f1a5%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637011969848063890&amp;sdata=fisvuf1k4d8Y1uzCVSYgcQcwHJz1aYIOxgq3XFCJVxI%3D&amp;reserved=0 >>> for MariaDB Connector J for this, which you may also use as a reference. Following is the detailed >>> description of the scenario and extension solution for PHP mysqlnd. >>> >>> Scenario (same as described in MDEV-15935): >>> Currently when multiple servers share one proxy, proxy forwards all the packets between >>> servers and clients. Thus, the proxy adds latency, take many computing resources and impacts the >>> overall performance. Especially for short connections scenarios like WordPress, the latency can be a >>> critical issue. >>> Supporting redirection mechanism is helpful for proxy-based scenario. It is more like >>> HTTP redirects or Oracle redirected connections. Clients get the servers' address from proxies >>> and connect to servers transparently without latency and computing resource wasted. >>> >>> Extension solution: >>> We implement the solution as a PECL style extension using mysqlnd plugin API, and the >>> basic idea is modifying the MYSQLND_METHOD(mysqlnd_data, connect) method, make it possible to >>> establish a new connection based on the redirection information provided by the response OK packet >>> in the last message field, and use the new connection if connection succeed. And then cache the >>> redirection information, so next time, it only need one establishment phase to connect to MySQL >>> server. >>> There are three MYSQLND_METHOD methods replaced as follows: >>> conn_m->connect = MYSQLND_METHOD(mysqlnd_rd, connect); >>> conn_d_m->connect = MYSQLND_METHOD(mysqlnd_rd_data, connect); >>> conn_d_m->dtor = MYSQLND_METHOD_PRIVATE(mysqlnd_rd_data, dtor); >>> >>> And I've modified the interface of MYSQLND_METHOD(mysqlnd_rd_data, connect) a >>> little, make the first parameter as MYSQLND_CONN_DATA ** instead of MYSQLND_CONN_DATA *, so I can >>> modify the content of the connection object the pointer points to. >>> After the first connection established and before send the init_command which may >>> update last message field: >>> { >>> const MYSQLND_CSTRING scheme = { transport.s, transport.l }; >>> if (FAIL == conn->m->connect_handshake(conn, &scheme, >>> &username, &password, &database, mysql_flags)) { >>> goto err; >>> } >>> } >>> Try to establish a new connection: >>> enum_func_status redirectState = >>> redirect_conn->m->connect_handshake(redirect_conn, &redirect_scheme, >>> &redirect_username, &password, &database, mysql_flags); If succeeds, close the original >>> connection, and update the connection information: >>> conn->m->send_close(conn); >>> conn->m->dtor(conn); >>> ... >>> conn = redirect_conn; >>> ... >>> *pconn = redirect_conn; //use new conn outside for caller >>> ... >>> hostname = redirect_hostname; >>> username = redirect_username; >>> port = ui_redirect_port; >> >> Thanks for the detailed explanation. From what I can tell, this looks good to me. >> >>> I've presented the code to @Christoph Becker (HAYS Professional Solutions >>> GM)<mailto:a-chbeck@microsoft.com> before. Since currently the >>> code is hold on a private repository, and there is a limit foe email size so I cannot add it in the >>> attachment, may I ask how should I present the code to you? >> >> One option could be to move it to a public Github repository. Some other PECL extensions >> are also hosted there (e.g. Imagick[1]). >> >>> The code does not have a package.xml yet, from >>> https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpear.php.net%2Fmanual%2Fen%2Fpyrus.commands.pickle.php&amp;data=02%7C01%7CQianqian.Bu%40microsoft.com%7C0f78a037b5ea42ccf72c08d71f02f1a5%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637011969848063890&amp;sdata=oEIPuR9x9owzZl3fsigRE5le%2Fzjj%2FWeiq6DRRqM2ME8%3D&amp;reserved=0 >>> it says that I can use picke with pyrus.phar to generate the package file, but it seems pyrus.phar >>> cannot work with PHP7. I cannot find pyrus.phar from pear2.php.net as described on >>> https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpear.php.net%2Fmanual%2Fen%2Finstallationpyrus.introduction.php&amp;data=02%7C01%7CQianqian.Bu%40microsoft.com%7C0f78a037b5ea42ccf72c08d71f02f1a5%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637011969848073885&amp;sdata=YDgKwPkqruUKhKP9BnaXDB7Vip9aJ43LgpK%2FvSCcAog%3D&amp;reserved=0,$(mîÿv¡˜Ý >>> „û_ and the download version from >>> https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fpyrus%2FPyrus&amp;data=02%7C01%7CQianqian.Bu%40microsoft.com%7C0f78a037b5ea42ccf72c08d71f02f1a5%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637011969848073885&amp;sdata=xOQz8ioJMZyMxi84G34hYSegpLlNsSxA0jbQRKFvyoQ%3D&amp;reserved=0 >>> does not work, and the repo has not been updated for many years. May I ask can you give me some help >>> about how to generate the package.xml file? >> >> I've filed a bug report regarding the obviously out-dated Pyrus >> documentation[2]. It seems to me that you would have to write the >> package.xml manually. :( >> >> [1] >> >> <https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit >> hub.com%2FImagick%2Fimagick&amp;data=02%7C01%7CQianqian.Bu%40microsoft >> .com%7C0f78a037b5ea42ccf72c08d71f02f1a5%7C72f988bf86f141af91ab2d7cd011 >> db47%7C1%7C0%7C637011969848073885&amp;sdata=vpUVVADXbyQMz5igkgYMqCZkvJ >> be5QLLd0G7%2BiMhIbA%3D&amp;reserved=0> >> [2] >> <òVRÜW"ŽÞ²ú‡Û >> ÄÔhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpea >> r.php.net%2Fbugs%2Fbug.php%3Fid%3D23840&amp;data=02%7C01%7CQianqian.Bu >> %40microsoft.com%7C0f78a037b5ea42ccf72c08d71f02f1a5%7C72f988bf86f141af >> 91ab2d7cd011db47%7C1%7C0%7C637011969848073885&amp;sdata=eAkV5avMBWi2e6 >> cWxzSXBrPlkXt115EGWuIpASHG4AM%3D&amp;reserved=0> >> >> Thanks, >> Christoph >> >

« previous php.pecl.dev (#16235) next »