Menu

Robust version based synchronization

Help
Anonymous
2009-03-16
2012-09-28
  • Anonymous

    Anonymous - 2009-03-16

    I have what I would assume is a common problem using HA-JDBC. I've managed to get the synchronization working with a differential strategy, BUT how do I ensure that I'm synchronizing correctly. Let me give you an example with two servers a and b both of these are active and synchronized with each other; server a goes down for maintainance, server b remains active and a bunch of things are created in the database, server b then goes down for maintainance, server a is started and then server b. When the synchronization kicks in (regardless of the approach taken) what stops the data from server b just being deleted.

    As far as I can tell, you would need to version the whole database to know the last time it was updated and therefore in which direction the synchronization should take place. There is also a problem when an "older" server is started first and then a more update server comes online, unfortunately, before this happened a bunch of data was written to the older server so now who is actually the most upto date?

    Anyone already solved problems like this?

     
    • Aristo

      Aristo - 2009-03-17

      I believe in this case we should implement our own synchronization strategy by implementing net.petrolink.hajdbc.sync.SynchronizationStrategy interface. You can look on the source code of HA-JDBC to give idea of how to implement this by yourself.

      You then can specify this synchronization strategy in config file. If you need additional parameter into your Synchronization strategy, you can also use java beans property in the your own strategy.

      For config file example, you implement your own strategy in com.foo.CustomSyncStrategy:

      <sync id="my_custom_strategy" class="com.foo.CustomSyncStrategy">
      <property name="custom_parameter1">12345</property>
      <property name="custom_parameter2">text1</property>
      </sync>

      Correct me if I am wrong, for a problem when an "older" server is started first and then a more update server comes online, as far as I know HA-JDBC will try for last recorded alive database as recorded (in Windows, is in HKEY_CURRENT_USER\Software\JavaSoft\Prefs\net\sf\hajdbc\local\&lt;database_name>, I don't know in other system ) and will throw error accordingly.

       
      • Paul Ferraro

        Paul Ferraro - 2009-03-17

        To clarify...
        HA-JDBC will never auto-deactivate the last active database in the cluster. This is meant to ensure that you never have the scenario where all databases are auto-deactivated and get auto-reactivated in the wrong order.
        You can, however, deactivate the last active database manually (i..e via JMX). If you do this, however, it is up to you to make sure you re-activate this database first, before re-activating any others. I think this is a reasonable solution. Thoughts?

         
        • Yury Soldak

          Yury Soldak - 2009-03-18

          Add this question and answer to (one of) FAQ ;)

          About the topic -- I agree with you. KISS, so say.

           

Log in to post a comment.