question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to implement mysql proxy?

See original GitHub issue

This is not a feature request, just a question. I have sphinxsearch with sql interface, and need to do transparent search index rebuild on configs change. Idea is to create second daemon for pushing new data, but use old one for search request until reindexing complete. Then reroute all “read” requests to new daemon.

As far as i understand, it would be convenient to have proxy, that can properly route sql requests and hide details from application.

Is it possible to do something like this with mysql2? I mean, it would be nice to serialize sql requests to some intermediate format (~ like AST in DOM) instead of binary protocol. Or can such task (proxy with intelligent routing) be implemented with different approach?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
puzrincommented, Sep 17, 2016

Thanks! We already migrated to mysql2 in forum convertor. General impression are:

  • seems to work without problems (5M posts conversion).
  • returning array container in promise interface looks a bit unusual, but i understand your reasons and that’s not critical in my case.
1reaction
sidorarescommented, Aug 18, 2016

@puzrin yeah if you expect this might happen ( connection does not respond for a very long time but TCP socket is alive ) then 1) connection commands queue start growing if you use connection directly or 2) pool callback queue would start growing if limit is not set

It’s still a useful feature, I’m keen to add it, but meanwhile you can have something like this:

   pool.getConnection( (err, conn) => {
      var timeout = setTimeout( () => {
          conn.close(); // this should trigger  removeFromPool - https://github.com/sidorares/node-mysql2/blob/b2010f99180d8b49eb7e9c2b6aeb8cb441362835/lib/pool_connection.js#L17-L21
      }, 30000);

      conn.query(sql, (err, res) => {
         conn.release();
         clearTimeout(timeout);
         // use result;
      });
   });

Read more comments on GitHub >

github_iconTop Results From Across the Web

MySQL Proxy
The proxy enables you to perform additional monitoring, filtering, or manipulation of queries without requiring you to make any modifications to the client...
Read more >
Getting started with MySQL Proxy
Create a Lua file, named first_example. · Assuming that your database server is on the same box, launch the proxy server · From...
Read more >
How To Use ProxySQL as a Load Balancer for MySQL on ...
Step 1 — Installing ProxySQL · Step 2 — Setting the ProxySQL Administrator Password · Step 3 — Configuring Monitoring in MySQL ·...
Read more >
ProxySQL - A High Performance Open Source MySQL Proxy
ProxySQL is a MySQL protocol proxy supporting Amazon Aurora, RDS, ClickHouse, Galera, Group Replication, MariaDB Server, NDB, Percona Server ...
Read more >
Chapter 16. MySQL Proxy
The proxy allows you to perform additional monitoring, filtering or manipulation on queries without you having to make any modifications to the client...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found