Comments on: Looking for a hack: share data between MySQL sessions https://shlomi-noach.github.io/blog/mysql/looking-for-a-hack-share-data-between-mysql-sessions Blog by Shlomi Noach Wed, 07 Jan 2015 10:25:08 +0000 hourly 1 https://wordpress.org/?v=5.3.3 By: Joro https://shlomi-noach.github.io/blog/mysql/looking-for-a-hack-share-data-between-mysql-sessions/comment-page-1#comment-302123 Wed, 07 Jan 2015 10:25:08 +0000 https://shlomi-noach.github.io/blog/?p=6034#comment-302123 Well, securty concerns about IPC are even harder, since the data are less defined than the tables.
So I don’t think you’ll be saving anything with avoiding the tables.

But if that must be done your option is to write a daemon plugin that has (any number of) global variables that processes can use to pass data around.
If you couple that with GET_LOCK() it may work.

But this will require super priv to set the global.

]]>
By: shlomi https://shlomi-noach.github.io/blog/mysql/looking-for-a-hack-share-data-between-mysql-sessions/comment-page-1#comment-301837 Tue, 06 Jan 2015 09:49:57 +0000 https://shlomi-noach.github.io/blog/?p=6034#comment-301837 I did not pursue this much further, so no…

]]>
By: Kushal https://shlomi-noach.github.io/blog/mysql/looking-for-a-hack-share-data-between-mysql-sessions/comment-page-1#comment-301014 Sat, 03 Jan 2015 18:33:33 +0000 https://shlomi-noach.github.io/blog/?p=6034#comment-301014 @shlomi Did you find a solution to this problem?

]]>
By: MySQL get_lock – STRUCTURED DATA UNSTRUCTURED DATA https://shlomi-noach.github.io/blog/mysql/looking-for-a-hack-share-data-between-mysql-sessions/comment-page-1#comment-183186 Thu, 21 Feb 2013 10:25:16 +0000 https://shlomi-noach.github.io/blog/?p=6034#comment-183186 […] 最近看到Shlomi Noach的blog(),分布式系统如何来做并发控制,一般情况,我们往往会使用一个表的一个记录来表示资源是否可用,但有个评论提到用mysql的get_lock函数,以前一直没有关注这个函数,今天小试一把。 […]

]]>
By: shlomi https://shlomi-noach.github.io/blog/mysql/looking-for-a-hack-share-data-between-mysql-sessions/comment-page-1#comment-171295 Thu, 31 Jan 2013 21:27:04 +0000 https://shlomi-noach.github.io/blog/?p=6034#comment-171295 @combuilder,

So the Stored Routines lib can dynamically get and set global variables — but that doesn’t help too much because those global variables have some important value, that I should not be tampering with.

]]>
By: combuilder https://shlomi-noach.github.io/blog/mysql/looking-for-a-hack-share-data-between-mysql-sessions/comment-page-1#comment-170311 Wed, 30 Jan 2013 11:39:55 +0000 https://shlomi-noach.github.io/blog/?p=6034#comment-170311 have you tried the global using this: http://sourceforge.net/projects/mysql-sr-lib/ ?

]]>
By: Maciej Dobrzanski https://shlomi-noach.github.io/blog/mysql/looking-for-a-hack-share-data-between-mysql-sessions/comment-page-1#comment-169471 Tue, 29 Jan 2013 10:05:35 +0000 https://shlomi-noach.github.io/blog/?p=6034#comment-169471 Justin,

The approach that uses process lists will not suffer from any permission-related problems as I assume both sessions would be using the same user, so they will be able to see each other in the process list even without the extra privilege.

]]>
By: Justin Swanhart https://shlomi-noach.github.io/blog/mysql/looking-for-a-hack-share-data-between-mysql-sessions/comment-page-1#comment-169458 Tue, 29 Jan 2013 09:44:10 +0000 https://shlomi-noach.github.io/blog/?p=6034#comment-169458 I know you said no UDF, but what you really want is gearman + Gearman MySQL UDF, but I know that they don’t have wide enough adoption for them to be usable by you. I figured I’d share this though, because you might think it is cool and it might let others know what you can do (anything you can image) with the UDFs.

It is how the Shard-Query MySQL proxy works, btw. The proxy intercepts the user’s original query, then runs a SQL call like this instead:
select gman_do(‘shard_query_worker’, v_orig_sql);

The gearman worker creates a Shard-Query object and executes the requested query. It then encodes the resultset in JSON in a representation friendly to the proxy so that it doesn’t have to reformulate it.

Since the results come back already properly formatted, the Lua script simply decodes the JSON and sends the array to the client as the result.

This makes the proxy very lightweight and unlikely to crash. Complex scripts are not very stable in my experience but simple ones are.

]]>
By: shlomi https://shlomi-noach.github.io/blog/mysql/looking-for-a-hack-share-data-between-mysql-sessions/comment-page-1#comment-169355 Tue, 29 Jan 2013 06:21:34 +0000 https://shlomi-noach.github.io/blog/?p=6034#comment-169355 Justin,

The VIEW solution brings back some memories from a similar old solution I used. Good call: will look into it!
Though in terms of infrastructure it still requires tables and GRANTs, there’s a lightweight essence to it. Thanks — will check it out.

]]>
By: shlomi https://shlomi-noach.github.io/blog/mysql/looking-for-a-hack-share-data-between-mysql-sessions/comment-page-1#comment-169353 Tue, 29 Jan 2013 06:15:20 +0000 https://shlomi-noach.github.io/blog/?p=6034#comment-169353 Justin, thanks.
As per Joro’s request, I’m elaborating:

I’m not too afraid of other people possibly reading the data interchanged between the two sessions.

I need this for my ongoing common_schema project, which is a sort of framework for MySQL. The need for inter-process communication is a shared part for several ideas. One of them would be the control of one “master” script or “dashboard” of some sorts, over scripts running in other connections (so, being able to gracefully stop them etc.).
Another idea involves controlling execution of stored routines (I won’t elaborate too much here, as I’ve only just started looking into this).

So basically, I will have:
One “master/dashboard/manager” connection, looking at “standard/worker” connections (one or more; if need be, I’m willing to settle for one).
The worker connections will send info about their state, and the manager connection will be able to send execution hints like “you should terminate now / you should resume now”.

There will be cooperation between the two; they just need to be able to pass info between themselves.

Like I said, I don’t care too much about eavesdropping at this moment.

If the solution is based on tables — which is the trivial way of sharing data between connections — then I already have all that I need. But this will of course require additional grants, which I prefer to avoid.

]]>