IceFireDB-SQLProxy

IceFireDB-SQLProxy #

A MySQL-protocol proxy that sits in front of ordinary MySQL servers and replays statements to the other agents in the mesh, so several MySQL instances in different places stay in step without changing the application.

cd IceFireDB-SQLProxy
make                                   # → bin/IceFireDB-SQLProxy
./bin/IceFireDB-SQLProxy -c ./config/config.yaml

mysql -h 127.0.0.1 -P 33306 -u host1 -p    # a user from userlist

What it is #

PropertyValue
ProtocolMySQL wire protocol
BackendMySQL (mysql.admin, mysql.readonly)
ReplicationStatements propagated between agents over libp2p
Listenerserver.addr, default :33306
Binarybin/IceFireDB-SQLProxy (-c <config.yaml>)

Configuration (config/config.yaml) #

KeyMeaningDefault in file
server.addrProxy listener":33306"
debug.enable / .portDebug/pprof servertrue / 17878
mysql.adminWrite connection pool: addr, user, password, dbname, minAlive, maxAlive, maxIdle127.0.0.1:3306, admin_user
mysql.readonlyRead connection pool, same keys127.0.0.1:3306, readonly_user
userlistClient tenants (user/password)host1 / host1
p2p.enableMesh replicationtrue
p2p.serviceDiscoveryIdRendezvous name, must match peerstanovo_sqlproxy_admin_service
p2p.serviceCommandTopicCommand channeltanovo_sqlproxy_command_topic
p2p.adminTopic / p2p.readonlyTopicPer-role channelstanovo_sqlproxy_admin_topic / …_readonly_topic
p2p.serviceDiscoverModeadvertise or announceadvertise
p2p.nodeHostIp / nodeHostPortAddress peers should dial127.0.0.1 / 0

Note the camelCase keys in this component (serviceDiscoveryId, not service_discovery_id as in PubSub/SQLite). Copying a config between components silently gives you a default value.

Operational notes #

  • Read/write separation is a config choice, not routing magic: mysql.readonly is the pool used for read queries, mysql.admin for writes. Point them at the same server if you have no replica.
  • Sample credentials (admin_pass, readonly_pass, host1/host1) are placeholders — replace them.
  • Statements replay to every agent, so deterministic SQL only. NOW()/RAND()/UUID() can diverge.
  • No conflict resolution: the mesh is ordered by arrival, so two agents writing the same row concurrently converge on whichever statement applies last.
  • The debug server is enabled in the sample config on port 17878; turn it off in production.

When to use it #

You already run MySQL and want the same data available closer to users in other regions without moving the application to a new database. It is not a MySQL cluster replacement: it does not do automatic failover of the MySQL backend, and it does not guarantee cross-site consistency for conflicting writes.