I created a test application to test HA-JDBC with:
- PostgreSQL;
- Hibernate;
- Spring + Spring Data JPA;
When I stop my second DBMS (databaseB), it is disabled and updates are done on my first DBMS.
But if I stop my first DBMS (databaseA), it doesn't disable and each operation to the database throws exceptions.
For this case, I observed:
- in step mode (debug): it works;
- if I set a Thread.sleep of 20 seconds between each database operation: it works;
- with 1 database operation per second: it doesn't work;
Did you re-activate databaseB prior to attempting to stop databaseA? HA-JDBC will persist the fact that databaseB is inactive - even after restarting your test/application. If this is the case, your cluster has only 1 remaining active database (databaseA) and HA-JDBC will never deactivate the last database node of a cluster, unless specifically configured to do so (i.e. <cluster allow-empty-cluster="true"/>)
Last edit: Paul Ferraro 2014-10-16
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
When starting my test the two databases are active. I checked with jconsole (JMX). By done, if I stop databaseA, it's databaseB which is disabled. It's very strange because it seemed to me yesterday that the two databases were still active.
I tried the allow-empty-cluster property for see: no change.
I disabled the cache (state): it's the same.
If I execute the isAlive method on cluster MBean, I have:
databaseA = false
databaseB = true
Which is correct for a shutdown of databaseA.
If I try to call the activate method of cluster MBean for databaseB, I throw an InvocationTargetException in jconsole.
As against, if:
* I set allow-empty-cluster="true";
* I stop databaseA: it's databaseB is disabled;
* I call the activate method for databaseB: it throw an InvocationTargetException;
* I call the deactivate method for databaseA;
* and I call the activate method for databaseB: it works.
Thank you,
Jean-Philippe MINETTI
Last edit: Jean-Philippe MINETTI 2014-10-17
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Attached to this post, the logs with exception after the attempt to activation of databaseB.
The InvocationTargetException appears in jconsole, but in the logs this is a JDBC exception (Connection refused. Check that the hostname and port are correct and that the postmaster accepting TCP / IP connections).
Regarding logs, in trace mode I have nothing else.
Other thing less important, in the logs, the WARN trace appears like this:
Na pas activé la base de données {0} du faisceau {1}
With MessageFormat, single quotes is used to not format text. You must double single quotes to ensure correct message as this:
N''a pas activé la base de données {0} du faisceau {1}
Sorry about those error messages - they were auto-generated (and probably out-of-date) and it looks like the quotes were mangled in the process. In master, I'm using gettext for log/error message i18n, for which users can contribute translations.
The last time I saw someone with this issue was because they had 2 server instances running HA-JDBC, where the definitions for each database were not the same (i.e. one server had databaseA pointing to 192.168.0.23, and databaseB pointing to 192.168.0.32; while the other server had databaseA pointing to 192.168.0.32 and databaseB pointing to 192.168.0.23). Are you certain this isn't the case?
You say that you stopped databaseA, but databaseB was disabled. There should be a log message that indicates why databaseB was disabled. Can you post that?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
To run: you need to create empty PostgreSQL databases; unzip the tar.gz; configure access to databases in files etc/datasources.xml and etc/ha-jdbc-mycluster.xml; type "bin/run create" to create the structure of databases on 2 DBMS;
* type "bin/run test2 --instance=XXX --insert=2 --update=1" to start the test.
Hi Paul,
I created a test application to test HA-JDBC with:
- PostgreSQL;
- Hibernate;
- Spring + Spring Data JPA;
When I stop my second DBMS (databaseB), it is disabled and updates are done on my first DBMS.
But if I stop my first DBMS (databaseA), it doesn't disable and each operation to the database throws exceptions.
For this case, I observed:
- in step mode (debug): it works;
- if I set a Thread.sleep of 20 seconds between each database operation: it works;
- with 1 database operation per second: it doesn't work;
My ha-jdbc-mycluster.xml:
My entityManagerFactory and datasource configuration (Spring):
My META-INF/persistence.xml:
Thanking you in advance,
Jean-Philippe MINETTI
Did you re-activate databaseB prior to attempting to stop databaseA? HA-JDBC will persist the fact that databaseB is inactive - even after restarting your test/application. If this is the case, your cluster has only 1 remaining active database (databaseA) and HA-JDBC will never deactivate the last database node of a cluster, unless specifically configured to do so (i.e. <cluster allow-empty-cluster="true"/>)
Last edit: Paul Ferraro 2014-10-16
When starting my test the two databases are active. I checked with jconsole (JMX). By done, if I stop databaseA, it's databaseB which is disabled. It's very strange because it seemed to me yesterday that the two databases were still active.
I tried the allow-empty-cluster property for see: no change.
I disabled the cache (state): it's the same.
If I execute the isAlive method on cluster MBean, I have:
databaseA = false
databaseB = true
Which is correct for a shutdown of databaseA.
If I try to call the activate method of cluster MBean for databaseB, I throw an InvocationTargetException in jconsole.
As against, if:
* I set allow-empty-cluster="true";
* I stop databaseA: it's databaseB is disabled;
* I call the activate method for databaseB: it throw an InvocationTargetException;
* I call the deactivate method for databaseA;
* and I call the activate method for databaseB: it works.
Thank you,
Jean-Philippe MINETTI
Last edit: Jean-Philippe MINETTI 2014-10-17
Can you provide more context for the InvocationTargetException? What stacktrace do you see in your log?
Hi Paul,
Attached to this post, the logs with exception after the attempt to activation of databaseB.
The InvocationTargetException appears in jconsole, but in the logs this is a JDBC exception (Connection refused. Check that the hostname and port are correct and that the postmaster accepting TCP / IP connections).
Regarding logs, in trace mode I have nothing else.
Other thing less important, in the logs, the WARN trace appears like this:
Na pas activé la base de données {0} du faisceau {1}
With MessageFormat, single quotes is used to not format text. You must double single quotes to ensure correct message as this:
N''a pas activé la base de données {0} du faisceau {1}
Jean-Philippe MINETTI
Hi Paul,
If you are unable to reproduce the problem, I can send you my test application (16.5 MB for binary) ?
Jean-Philippe MINETTI
Sorry about those error messages - they were auto-generated (and probably out-of-date) and it looks like the quotes were mangled in the process. In master, I'm using gettext for log/error message i18n, for which users can contribute translations.
The last time I saw someone with this issue was because they had 2 server instances running HA-JDBC, where the definitions for each database were not the same (i.e. one server had databaseA pointing to 192.168.0.23, and databaseB pointing to 192.168.0.32; while the other server had databaseA pointing to 192.168.0.32 and databaseB pointing to 192.168.0.23). Are you certain this isn't the case?
You say that you stopped databaseA, but databaseB was disabled. There should be a log message that indicates why databaseB was disabled. Can you post that?
No, for the last test, I used a single server instance running HA-JDBC. It can not be that.
Attached to this post, my last logs just before databaseA stopping.
A small detail that may be important, I have two threads (UPDATE and INSERT in logs).
Jean-Philippe MINETTI
Last edit: Jean-Philippe MINETTI 2014-10-22
Hi Paul,
Were you able to reproduce the problem ?
If not, I can send you the binaries and/or sources of my test application ?
Jean-Philippe MINETTI
Can you post a test that reproduces the problem?
Hi Paul,
Attached to this post, the binary.
To run:
you need to create empty PostgreSQL databases;
unzip the tar.gz;
configure access to databases in files etc/datasources.xml and etc/ha-jdbc-mycluster.xml;
type "bin/run create" to create the structure of databases on 2 DBMS;
* type "bin/run test2 --instance=XXX --insert=2 --update=1" to start the test.
...
...
and attached to this post, the source.
Jean-Philippe MINETTI