activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Archibald <>
Subject Re: [ARTEMIS] Server doesn't start if JDBC store is used and table NODE_MANAGER_STORE is empty
Date Sat, 27 Jan 2018 18:26:43 GMT
Thanks Franz, 

this sounds all supi-dupi interesting but has nothing to with the issue. 
It is as simple as I noticed.
>From the code:
protected void createSchema() throws SQLException {
      try {
sqlProvider.createNodeIdSQL(), sqlProvider.createStateSQL(),
sqlProvider.createLiveLockSQL(), sqlProvider.createBackupLockSQL());
      } catch (SQLException e) {
         //no op: if a table already exists is not a problem in this case,
the prepareStatements() call will fail right after it if the table is not
correctly initialized
         if (logger.isDebugEnabled()) {
            logger.debug("Error while creating the schema of the JDBC shared
state manager", e);

Obviously here the table is being created along with some other initial data

Then later in

private static void createTableIfNotExists(Connection connection,
                                              String tableName,
                                              String... sqls) throws
SQLException {
      logger.tracef("Validating if table %s didn't exist before creating",
      try {
         try (ResultSet rs = connection.getMetaData().getTables(null, null,
tableName, null)) {
            if (rs != null && ! {
               if (logger.isTraceEnabled()) {
                  logger.tracef("Table %s did not exist, creating it with
SQL=%s", tableName, Arrays.toString(sqls));
               final SQLWarning sqlWarning = rs.getWarnings();
               if (sqlWarning != null) {
StringBuilder(), sqlWarning));
               try (Statement statement = connection.createStatement()) {
                  for (String sql : sqls) {
                     final SQLWarning statementSqlWarning =
                     if (statementSqlWarning != null) {
StringBuilder(), statementSqlWarning, sql));

So if table exists, don't do anything. If it doesn't exist, fill with
initial data.

This implementation could be improved by the case where the table exists,
but is empty which should lead to the same initial setup as the case where
the table does not exist.

Can this be fixed? 


Sent from:

View raw message