logic help

I am thinking of make a control panel for creating db's. Both the db and cp will be on seperate vps's and I was trying to think how it can be controlled. This was my idea:

Simple sqlite db on the cp vps with the app -

Create instanse vars for the username,dbname,password -

Method for creating the user,db etc -

If this passes it adds to the sqlite db

or the reverse of this but i issue i can see is that if the method passes but the local db insert fails it will create the db on the server but no entry in the local db, this is also the same if you reverse the order so creating the local db entry first and then running the method to create the db on the remote server.

How could this be done so that whatever way if the db is create or the local db entry is create the oppsite will be created or not created depending on which ever failes.

This is more complex than you might imagine, replicating databases and their data across multiple domains is a pure nightmare. The approach you are suggesting is so full of holes I don't know where to start so I'll start with the usual question when faced with requirements like this which is

Why?

I mean why replicate databases across domains, that is the roll of very advanced load balancing software of which I am sure there are some awesome open source options.

This is more complex than you might imagine, replicating databases and their data across multiple domains is a pure nightmare. The approach you are suggesting is so full of holes I don't know where to start so I'll start with the usual question when faced with requirements like this which is

Why?

I mean why replicate databases across domains, that is the roll of very advanced load balancing software of which I am sure there are some awesome open source options.

Sorry for the delay I have been a bit busy.

Again sorry I might have not explained myself correctly. This is not database replication. The control panel keeps track of db on the db server so if i create a db on the cp server it send the command to create the db on the db server but adds a entry in it's local db to say that it's been created. So then if i want to remove the db I would remove the entry on the local db of the cp server and then it would send the command to remove the db from the db server.

The problem I saw was if there is any any failure of creating the db via the command or saving the entry there would be either the local db entry or the created db and not the other so the db would be created but the local db may not be or the other way around.

I guess you just need a way to check that the remote functions worked when maintaining the remote db.

You create your record in the cp database and flag it as awaiting process, you have a cron job running somewhere that uses a rake task that is looking for records flagged as awaiting process. The task then does it job of communicating with the remote server telling it to do whatever it has to do, create or delete, then on success the flag gets set to completed on the cp record.