You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by franz1981 <gi...@git.apache.org> on 2017/10/05 16:09:16 UTC

[GitHub] activemq-artemis pull request #1576: ARTEMIS-1447 JDBC NodeManager to suppor...

GitHub user franz1981 opened a pull request:

    https://github.com/apache/activemq-artemis/pull/1576

    ARTEMIS-1447 JDBC NodeManager to support JDBC HA Shared Store

    It implements the JDBC NodeManager to support HA with a JDBC Shared Store.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/franz1981/activemq-artemis ha_jdbc

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/activemq-artemis/pull/1576.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #1576
    
----
commit 3aa6dbfc5b0bad94c8cdcbebfd7ddecd660ac175
Author: Francesco Nigro <ni...@gmail.com>
Date:   2017-09-09T16:41:30Z

    ARTEMIS-1447 JDBC NodeManager to support JDBC HA Shared Store

----


---

[GitHub] activemq-artemis issue #1576: ARTEMIS-1447 JDBC NodeManager to support JDBC ...

Posted by franz1981 <gi...@git.apache.org>.
Github user franz1981 commented on the issue:

    https://github.com/apache/activemq-artemis/pull/1576
  
    @clebertsuconic You're right, I need to take a better example to explain what I mean.
    Quoting from the `CriticalAnaylizerImpl`:
    
    ```
          // we are not using any Thread Pool or any Scheduled Executors from the ArtemisServer
          // as that would defeat the purpose,
          // as in any deadlocks the schedulers may be starving for something not responding fast enough
          thread = new Thread("Artemis Critical Analyzer")
    ```
    The reason is similar: if for any reason (eg deadlocks/long JVM pauses/a single long running task) the live/backup locks wouldn't be renewed with the correct timing (ie not a matter to be fast but with a correct timing), the mechanics of the node manager will be compromised. It sounds cathastrofic but is the same limitation of the original JDBC lock of ActiveMQ 6: [LeaseDatabaseLocker](https://github.com/apache/activemq/blob/master/activemq-jdbc-store/src/main/java/org/apache/activemq/store/jdbc/LeaseDatabaseLocker.java ).
    Hence I need 2 executors that cannot be shared with none in order to minimize the chance of being slowed down.
    To summarize:
    > if you need your own executor, still use the component which encapsulates that.. 
    
    I need 2 of them (live + backup), not shared and to use `scheduleWithFixedRate` instead of `scheduleWithFixedDelay` used in the `ActiveMQScheduledComponent`: probably is not the right choice.
    
    > if you can reuse one from the pool.. (It seems you can).. you can just pass in the argument.
    
    I can pass them in the argument, but given that I need them to be unshared and I can't be sure of it if they will be instantiated elsewhere.
    
    In order to use your advice what I can do (maybe similar) is to pass a common thread pool and run the scheduled executors on top of it.
    
    And Re the package there is a good place (and module) in your opinion where I could move the classes?
    
    
    
    
    
    
    



---

[GitHub] activemq-artemis issue #1576: ARTEMIS-1447 JDBC NodeManager to support JDBC ...

Posted by mtaylor <gi...@git.apache.org>.
Github user mtaylor commented on the issue:

    https://github.com/apache/activemq-artemis/pull/1576
  
    @franz1981 It was an example.  You could instead do what the text is suggesting and just catch the SQLException and re-establish it yourself.  My point is to do the basic thing for the functionality to work, then optimise later.  We don't need a full connection pooling mechanism just to re-establish a connection should one fail.


---

[GitHub] activemq-artemis issue #1576: ARTEMIS-1447 JDBC NodeManager to support JDBC ...

Posted by clebertsuconic <gi...@git.apache.org>.
Github user clebertsuconic commented on the issue:

    https://github.com/apache/activemq-artemis/pull/1576
  
    Nice job!



---

[GitHub] activemq-artemis issue #1576: ARTEMIS-1447 JDBC NodeManager to support JDBC ...

Posted by mtaylor <gi...@git.apache.org>.
Github user mtaylor commented on the issue:

    https://github.com/apache/activemq-artemis/pull/1576
  
    @franz1981 Yes, I meant using a generic connection pool implementations as they reset the connection on release for isolation across components sharing the same pool.  I understand that reconnect is not part of the spec, but it's such a fundamental piece of functionality I'd be surprised if it wasn't already handled in drivers for all our supported DBs.  
    
    I'm not against the idea of using a connection pool (I responded to the comment and missed the fact that you'd implemented your own pool).  This is all good, but is it required for this JIRA?  It's more complexity that may not be required.  For what you're trying to achieve a generic pool would probably suffice.  How about doing something simple for stage 1 to get the HA functionality working.  We can optimise when required.  I would suggest, getting the basic stuff in commit 1, and optimisations in subsequent commits (could be the same PR) but makes it a lot easier to review and track down issues later.


---

[GitHub] activemq-artemis issue #1576: ARTEMIS-1447 JDBC NodeManager to support JDBC ...

Posted by clebertsuconic <gi...@git.apache.org>.
Github user clebertsuconic commented on the issue:

    https://github.com/apache/activemq-artemis/pull/1576
  
    @franz1981 the ActiveMQScheduledComponent was a suggestion BTW.. do what's right.. even if we need to refactor later...
    
    if you make the impl easier to understand it's fine.


---

[GitHub] activemq-artemis issue #1576: ARTEMIS-1447 JDBC NodeManager to support JDBC ...

Posted by clebertsuconic <gi...@git.apache.org>.
Github user clebertsuconic commented on the issue:

    https://github.com/apache/activemq-artemis/pull/1576
  
    ```
          insertStateOnNodeManagerStoreTableSQL = "INSERT INTO " + tableName + " (ID) VALUES (0)";
          insertNodeIdOnNodeManagerStoreTableSQL = "INSERT INTO " + tableName + " (ID) VALUES (3)";
          insertLiveLockOnNodeManagerStoreTableSQL = "INSERT INTO " + tableName + " (ID) VALUES (1)";
          insertBackupLockOnNodeManagerStoreTableSQL = "INSERT INTO " + tableName + " (ID) VALUES (2)";
    ```
    
    Wouldn't be better to have a single statement (Using a separate table as I had already asked).. using prepared statements?
    
    I'm a bit concerned also that the semantic of 1, 2 and 3.. is inside the literal string.. and I see no references on the LeaseLock implementation. I wouldn't understand how to debug this.. it makes it harder to maintain IMO.


---

[GitHub] activemq-artemis pull request #1576: ARTEMIS-1447 JDBC NodeManager to suppor...

Posted by clebertsuconic <gi...@git.apache.org>.
Github user clebertsuconic commented on a diff in the pull request:

    https://github.com/apache/activemq-artemis/pull/1576#discussion_r147246049
  
    --- Diff: artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/jdbc/ScheduledLeaseLock.java ---
    @@ -0,0 +1,44 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements. See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License. You may obtain a copy of the License at
    + *
    + * http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.activemq.artemis.core.server.impl.jdbc;
    +
    +import java.util.concurrent.ScheduledExecutorService;
    +
    +import org.apache.activemq.artemis.core.io.IOCriticalErrorListener;
    +import org.apache.activemq.artemis.core.server.ActiveMQComponent;
    +import org.apache.activemq.artemis.utils.actors.ArtemisExecutor;
    +
    +/**
    + * {@link LeaseLock} holder that allows to schedule a {@link LeaseLock#renew} task with a fixed {@link #renewPeriodMillis()} delay.
    + */
    +interface ScheduledLeaseLock extends ActiveMQComponent {
    +
    +   LeaseLock lock();
    +
    +   long renewPeriodMillis();
    +
    +   static ScheduledLeaseLock of(ScheduledExecutorService scheduledExecutorService,
    --- End diff --
    
    @franz1981 the only thing I didn't like was the name of this method :)
    
    I would have chosen build.. newInstance... 
    
    But I will take it as a personal choice.. will just merge it 👍 


---

[GitHub] activemq-artemis issue #1576: ARTEMIS-1447 JDBC NodeManager to support JDBC ...

Posted by franz1981 <gi...@git.apache.org>.
Github user franz1981 commented on the issue:

    https://github.com/apache/activemq-artemis/pull/1576
  
    @clebertsuconic  @mtaylor I'm already using prepared statements with different parameters but each row id can have only one meaning (live lock, backup lock,nodeId and state) hence it's better IMO to have a clear distinction between them as it is now: you can't have more than 2 rows to hold locks and it is the same with the other rows.
    
    @clebertsuconic I've refactored the classes into a 'jdbc' package and I've built an high level abstraction to manage the scheduling of the locks using a common Artemis scheduled component implementation.
    Right now most classes will be package private in order to prohibit any other use until (if) the file based lock NodeManager will be refactored using them.


---

[GitHub] activemq-artemis issue #1576: ARTEMIS-1447 JDBC NodeManager to support JDBC ...

Posted by franz1981 <gi...@git.apache.org>.
Github user franz1981 commented on the issue:

    https://github.com/apache/activemq-artemis/pull/1576
  
    @mtaylor Yes i understand but quoting it:
    
    > The use of this feature is not recommended, because it has side effects related to session state and data consistency when applications don't handle SQLExceptions properly, and is only designed to be used when you are unable to configure your application to handle SQLExceptions resulting from dead and stale connections properly. Alternatively, as a last option, investigate setting the MySQL server variable "wait_timeout" to a high value, rather than the default of 8 hours.
    
    > Default: false
    
    I think that providing (if necessary as you said) an application level pool is a better chance to have something that could work across vendors.


---

[GitHub] activemq-artemis pull request #1576: ARTEMIS-1447 JDBC NodeManager to suppor...

Posted by michaelandrepearce <gi...@git.apache.org>.
Github user michaelandrepearce commented on a diff in the pull request:

    https://github.com/apache/activemq-artemis/pull/1576#discussion_r142992370
  
    --- Diff: artemis-server/src/main/resources/schema/artemis-configuration.xsd ---
    @@ -1830,6 +1830,27 @@
                    </xsd:documentation>
                 </xsd:annotation>
              </xsd:element>
    +         <xsd:element name="jdbc-lock-acquisition-timeout" type="xsd:int" minOccurs="0" maxOccurs="1">
    --- End diff --
    
    There is a lot of JDBC config, is it maybe worth making a JDBC config section and type, so its more contained


---

[GitHub] activemq-artemis issue #1576: ARTEMIS-1447 JDBC NodeManager to support JDBC ...

Posted by franz1981 <gi...@git.apache.org>.
Github user franz1981 commented on the issue:

    https://github.com/apache/activemq-artemis/pull/1576
  
    @clebertsuconic AFAIK @mtaylor is not using any connection pool ie if the connection drop, no reconnection will happen. 
    
    > Also: I see an issue with threads.. if an executor is used.. you may get many connections used?
    
    Depends: my use case (one of the reasons why most utils classes are package private) is sligthly different: most of the connection usages are single threaded and consecutive (eg NodeManager::awaitLiveNode) and many DBMS will expire long running connections by default, so I wouldn't be worried to have many "leaky" opened connections.
    I can see (talking with @mtaylor) if i can make my use case even simpler and avoid a pool at all, but managing the reconnect


---

[GitHub] activemq-artemis pull request #1576: ARTEMIS-1447 JDBC NodeManager to suppor...

Posted by michaelandrepearce <gi...@git.apache.org>.
Github user michaelandrepearce commented on a diff in the pull request:

    https://github.com/apache/activemq-artemis/pull/1576#discussion_r142992780
  
    --- Diff: artemis-server/src/main/resources/schema/artemis-configuration.xsd ---
    @@ -1830,6 +1830,27 @@
                    </xsd:documentation>
                 </xsd:annotation>
              </xsd:element>
    +         <xsd:element name="jdbc-lock-acquisition-timeout" type="xsd:int" minOccurs="0" maxOccurs="1">
    --- End diff --
    
    ignore this, i didn't realise its within a database store type already...helps to read up


---

[GitHub] activemq-artemis issue #1576: ARTEMIS-1447 JDBC NodeManager to support JDBC ...

Posted by mtaylor <gi...@git.apache.org>.
Github user mtaylor commented on the issue:

    https://github.com/apache/activemq-artemis/pull/1576
  
    @franz1981 I think using a single class to hold the database statements is fine.  Splitting this up into several classes would mean that every provider would have to override 3 or 4 classes just to change the DB statements.  Unless there's a technical reason to do it, like having to use two tables in a single statement, then I wouldn't bother.
    
    Another note.  I haven't checked these statements work with Derby, but I don't see any overrides in Oracle12C provider.  Please ensure that the tests run and pass with Derby, as this is the default provider in our test suite.  Override them in Oracle12C etc...


---

[GitHub] activemq-artemis issue #1576: ARTEMIS-1447 JDBC NodeManager to support JDBC ...

Posted by clebertsuconic <gi...@git.apache.org>.
Github user clebertsuconic commented on the issue:

    https://github.com/apache/activemq-artemis/pull/1576
  
    for the JdbcNodeManager:
    
    The package server.impl is already bloated.. I tried once to refactor it into smaller packages...
    
    This is a nice abstract model you have, but instead of the big class, cal you create a packet jdbcNodeManager, and add your classes there?
    
    
    
    Also, instead of creating your own scheduledExecutor.. Please extend ActiveMQScheduledComponent... if you can reuse the same executors that we already have created, just pass in the scheduledService as a parameter... and if you must create a new ScheduledService, you can still use the same class for that.


---

[GitHub] activemq-artemis issue #1576: ARTEMIS-1447 JDBC NodeManager to support JDBC ...

Posted by clebertsuconic <gi...@git.apache.org>.
Github user clebertsuconic commented on the issue:

    https://github.com/apache/activemq-artemis/pull/1576
  
    Instead of using the Journal Table for the locks... please create another Table for that.
    
    To be honest... I don't understand what's going on with the data.. and this will be pretty hard to be maintained by someone else if you just use a single table for things like this.


---

[GitHub] activemq-artemis issue #1576: ARTEMIS-1447 JDBC NodeManager to support JDBC ...

Posted by franz1981 <gi...@git.apache.org>.
Github user franz1981 commented on the issue:

    https://github.com/apache/activemq-artemis/pull/1576
  
    @clebertsuconic 
    This is the change I've mentioned above: https://github.com/apache/activemq-artemis/pull/1586



---

[GitHub] activemq-artemis issue #1576: ARTEMIS-1447 JDBC NodeManager to support JDBC ...

Posted by franz1981 <gi...@git.apache.org>.
Github user franz1981 commented on the issue:

    https://github.com/apache/activemq-artemis/pull/1576
  
    @mtaylor 
    > Each time a connection is released back to the pool, the prepared statements need to be reinitialized.
    
    I haven't understood it: do you mean in a generic pool implementation (eg [HIkariCP](https://github.com/brettwooldridge/HikariCP)) or in the one I've done?
    
    > Did you look to see if reconnects are handled by the JDBC driver? I'd expect the JDBC client libs to take care of reconnects after a drop, meaning we don't have to think about this at the application level.
    
    Yes and in the [JDBC 4.1 spec](https://www.google.it/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0ahUKEwjmj9vss_fWAhUSaFAKHc67D90QFggnMAA&url=http%3A%2F%2Fdownload.oracle.com%2Fotn-pub%2Fjcp%2Fjdbc-4_1-mrel-eval-spec%2Fjdbc4.1-fr-spec.pdf&usg=AOvVaw0pEUpMaXVVBk19KJsXuaaU) there is no mention about it. I suspect this is the reason why are provided operations on the Connection as setNetworkTimeout and isValid: in order to have a platform indipendent way to manage reconnection/failures management on application level.
    
    > We may at some point in the future want to manage our own connection pool. SQLFileFactory would benefit from this. At the journal level, we would need to refactor to sync at the operational context level. I'm not against using the Connection Pool to handle the optmistic lock, as it doesn't affect perf.
    
    Agree!



---

[GitHub] activemq-artemis issue #1576: ARTEMIS-1447 JDBC NodeManager to support JDBC ...

Posted by franz1981 <gi...@git.apache.org>.
Github user franz1981 commented on the issue:

    https://github.com/apache/activemq-artemis/pull/1576
  
    @clebertsuconic @mtaylor I will provide soon a pool free commit too :+1: 


---

[GitHub] activemq-artemis issue #1576: ARTEMIS-1447 JDBC NodeManager to support JDBC ...

Posted by franz1981 <gi...@git.apache.org>.
Github user franz1981 commented on the issue:

    https://github.com/apache/activemq-artemis/pull/1576
  
    @mtaylor 
    @clebertsuconic 
    > I think using a single class to hold the database statements is fine.
    
    Agree!
    >Another note. I haven't checked these statements work with Derby, but I don't see any overrides in Oracle12C provider. Please ensure that the tests run and pass with Derby, as this is the default provider in our test suite. Override them in Oracle12C etc...
    
    The tests run fine with Derby and MySQL while the other DBMS need futher testing: I've used http://sqlfiddle.com/ to test vs Oracle but is not enough.


---

[GitHub] activemq-artemis issue #1576: ARTEMIS-1447 JDBC NodeManager to support JDBC ...

Posted by franz1981 <gi...@git.apache.org>.
Github user franz1981 commented on the issue:

    https://github.com/apache/activemq-artemis/pull/1576
  
    @mtaylor @clebertsuconic I've added a second commit that uses the AbstractJDBCDriver and use one connection for everything (+ it caches the prepared statements as the AbstractJDBCDriver implementation suggest). Let me know if it seems ok. I just need to retry the failover tests on it too and If it will pass the reviews I'll squash it.


---

[GitHub] activemq-artemis issue #1576: ARTEMIS-1447 JDBC NodeManager to support JDBC ...

Posted by clebertsuconic <gi...@git.apache.org>.
Github user clebertsuconic commented on the issue:

    https://github.com/apache/activemq-artemis/pull/1576
  
    ActiveMQScheduledComponent can manage its own ScheduledExecutor if you need it... just reuse the class please?


---

[GitHub] activemq-artemis issue #1576: ARTEMIS-1447 JDBC NodeManager to support JDBC ...

Posted by franz1981 <gi...@git.apache.org>.
Github user franz1981 commented on the issue:

    https://github.com/apache/activemq-artemis/pull/1576
  
    @mtaylor wdyt?
    
    > One thing regarding the SQL Provider.. you use the same class for all the statements. Perhaps needs to be refactored...
    
    > So, if you for now just avoid constants in your statements.. and isolate the statements well with clear docs.. perhaps we can refactor this in better terms. If you pass in arguments to your statements directly from your internal enumerations it would be easier to understand what's going on.



---

[GitHub] activemq-artemis issue #1576: ARTEMIS-1447 JDBC NodeManager to support JDBC ...

Posted by clebertsuconic <gi...@git.apache.org>.
Github user clebertsuconic commented on the issue:

    https://github.com/apache/activemq-artemis/pull/1576
  
    @franz1981  you're using your own Pool Infrastructure.. differently than what Martyn used?
    did you check what @mtaylor used here?
    
    Also: I see an issue with threads.. if an executor is used.. you may get many connections used?



---

[GitHub] activemq-artemis issue #1576: ARTEMIS-1447 JDBC NodeManager to support JDBC ...

Posted by franz1981 <gi...@git.apache.org>.
Github user franz1981 commented on the issue:

    https://github.com/apache/activemq-artemis/pull/1576
  
    I will provide soon other commits with the modified NettyFailoverTest tests and docs: I've pushed it now in order to receive the first feedbacks/opinions/reviews :+1: 


---

[GitHub] activemq-artemis issue #1576: ARTEMIS-1447 JDBC NodeManager to support JDBC ...

Posted by franz1981 <gi...@git.apache.org>.
Github user franz1981 commented on the issue:

    https://github.com/apache/activemq-artemis/pull/1576
  
    @clebertsuconic I have to modify it first: ActiveMQScheduledComponent has only 1 ScheduledExecutor (while i need 2) and it can trigger tasks only with fixed delay while I need to trigger them with a fixed rate.


---

[GitHub] activemq-artemis pull request #1576: ARTEMIS-1447 JDBC NodeManager to suppor...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/activemq-artemis/pull/1576


---

[GitHub] activemq-artemis issue #1576: ARTEMIS-1447 JDBC NodeManager to support JDBC ...

Posted by michaelandrepearce <gi...@git.apache.org>.
Github user michaelandrepearce commented on the issue:

    https://github.com/apache/activemq-artemis/pull/1576
  
    @franz1981 sure makes sense :)


---

[GitHub] activemq-artemis issue #1576: ARTEMIS-1447 JDBC NodeManager to support JDBC ...

Posted by mtaylor <gi...@git.apache.org>.
Github user mtaylor commented on the issue:

    https://github.com/apache/activemq-artemis/pull/1576
  
    @franz1981 See the HA section here: https://dev.mysql.com/doc/connector-j/5.1/en/connector-j-reference-configuration-properties.html as an example of what I am thinking about.  You could of course just attempt to reconnect when you receive teh SQLException.


---

[GitHub] activemq-artemis issue #1576: ARTEMIS-1447 JDBC NodeManager to support JDBC ...

Posted by clebertsuconic <gi...@git.apache.org>.
Github user clebertsuconic commented on the issue:

    https://github.com/apache/activemq-artemis/pull/1576
  
    One thing regarding the SQL Provider.. you use the same class for all the statements. Perhaps needs to be refactored... 
    
    So, if you for now just avoid constants in your statements.. and isolate the statements well with clear docs.. perhaps we can refactor this in better terms. If you pass in arguments to your statements directly from your internal enumerations it would be easier to understand what's going on.


---

[GitHub] activemq-artemis issue #1576: ARTEMIS-1447 JDBC NodeManager to support JDBC ...

Posted by michaelandrepearce <gi...@git.apache.org>.
Github user michaelandrepearce commented on the issue:

    https://github.com/apache/activemq-artemis/pull/1576
  
    @franz1981 is any of this exposed in controls for JDBC, so it can be seen , configured and adjusted via console/management api? Like it is for Journal based.


---

[GitHub] activemq-artemis issue #1576: ARTEMIS-1447 JDBC NodeManager to support JDBC ...

Posted by franz1981 <gi...@git.apache.org>.
Github user franz1981 commented on the issue:

    https://github.com/apache/activemq-artemis/pull/1576
  
    @gtully Considering the mechanics of not pooling connections what could be sane default to expire/renew the locks? 
    I'm testing it with Oracle 12c and it is very slow, so probably I will perform some more checks to detect slowness.


---

[GitHub] activemq-artemis issue #1576: ARTEMIS-1447 JDBC NodeManager to support JDBC ...

Posted by franz1981 <gi...@git.apache.org>.
Github user franz1981 commented on the issue:

    https://github.com/apache/activemq-artemis/pull/1576
  
    @michaelandrepearce Good point! As soon as this passed the reviews I will make them visible into it, but probably not configurable! 


---

[GitHub] activemq-artemis issue #1576: ARTEMIS-1447 JDBC NodeManager to support JDBC ...

Posted by franz1981 <gi...@git.apache.org>.
Github user franz1981 commented on the issue:

    https://github.com/apache/activemq-artemis/pull/1576
  
    @clebertsuconic 
    > Instead of using the Journal Table for the locks... please create another Table for that.
    
    The node manager is already using a table different from the Journal Table to store the locks/NodeId/state:
    
    ``// Default node manager store table name, used with Database storage type
     private static final String DEFAULT_NODE_MANAGER_STORE_TABLE_NAME = "NODE_MANAGER_STORE";``
    
    > To be honest... I don't understand what's going on with the data.. and this will be pretty hard to be maintained by someone else if you just use a single table for things like this.
    
    You're right, but I've implemented exactly the same data processing (and layout) of [FileLockNodeManager](https://github.com/apache/activemq-artemis/blob/master/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/FileLockNodeManager.java), hence I probably need to document it in both, given that is 1:1 with it: makes sense?
    
    >The package server.impl is already bloated.. I tried once to refactor it into smaller packages...
    This is a nice abstract model you have, but instead of the big class, cal you create a packet jdbcNodeManager, and add your classes there?
    
    Yes, good point: I'll do it :+1: 
    
    >Also, instead of creating your own scheduledExecutor.. Please extend ActiveMQScheduledComponent... if you can reuse the same executors that we already have created, just pass in the scheduledService as a parameter... and if you must create a new ScheduledService, you can still use the same class for that.
    
    I'm not sure about it: it's similar to the TimedBuffer flusher thread. 
    It (they) needs to not being slowed down by anything in order to work as expected and I've put several checks that will be triggered otherwise. 
    If we have already something similar that I can reuse I will do it for sure.
    
    > Wouldn't be better to have a single statement (Using a separate table as I had already asked).. using prepared statements?
    Each line can be used for just one purpose and you can't have more than one line doing it, exactly as the file based NodeManager: IMHO is more dangerous/complex to have a prepared statement here.
    
    >I'm a bit concerned also that the semantic of 1, 2 and 3.. is inside the literal string.. and I see no references on the LeaseLock implementation. I wouldn't understand how to debug this.. it makes it harder to maintain IMO.
    
    Agree :+1:  It is not clear and need more docs as I've answered above on another point.
    
    Considering how it works the only improvement I would do on the data layout is to use 2 different tables,`NODE_MANAGER_STORE_LOCKS` and `NODE_MANAGER_STORE_STATE`, to separate the locks and the shared state data.
    TBH, considering that the first table will have just 2 rows and the second just 1, probably it is not a big improvement that justify the change: keep it simpler probably is a best deal.
    



---

[GitHub] activemq-artemis issue #1576: ARTEMIS-1447 JDBC NodeManager to support JDBC ...

Posted by mtaylor <gi...@git.apache.org>.
Github user mtaylor commented on the issue:

    https://github.com/apache/activemq-artemis/pull/1576
  
    @franz1981 @clebertsuconic The reason we don';t use connection pools is to increase performance on journal syncs.  Each time a connection is released back to the pool, the prepared statements need to be reinitialized.  @franz1981 I am not sure your statement is correct:
    
    ```
     ie if the connection drop, no reconnection will happen.
    ```
    
    Did you look to see if reconnects are handled by the JDBC driver?  I'd expect the JDBC client libs to take care of reconnects after a drop, meaning we don't have to think about this at the application level.
    
    We may at some point in the future want to manage our own connection pool.  SQLFileFactory would benefit from this.  At the journal level, we would need to refactor to sync at the operational context level.  I'm not against using the Connection Pool to handle the optmistic lock, as it doesn't affect perf.  But please ensure your assertion is correct before proceeding :).


---

[GitHub] activemq-artemis issue #1576: ARTEMIS-1447 JDBC NodeManager to support JDBC ...

Posted by clebertsuconic <gi...@git.apache.org>.
Github user clebertsuconic commented on the issue:

    https://github.com/apache/activemq-artemis/pull/1576
  
    As long as you don't keep semantics within the statements it's fine... just use prepared statements... there are way too many statements created for all the state possible combinations now.


---

[GitHub] activemq-artemis issue #1576: ARTEMIS-1447 JDBC NodeManager to support JDBC ...

Posted by clebertsuconic <gi...@git.apache.org>.
Github user clebertsuconic commented on the issue:

    https://github.com/apache/activemq-artemis/pull/1576
  
    You can just a single one... the ActiveMQScheduledComponent uses an executor... once the timer is reached.. it will call the executor... 
    
    I would be careful on adding a lot of threads on the broker...
    
    
    Try reusing the already existent ShceduledExecutor...
    
    
    if you at least reuse the component it's easier to change it IMO.


---

[GitHub] activemq-artemis issue #1576: ARTEMIS-1447 JDBC NodeManager to support JDBC ...

Posted by clebertsuconic <gi...@git.apache.org>.
Github user clebertsuconic commented on the issue:

    https://github.com/apache/activemq-artemis/pull/1576
  
       I'm not sure about it: it's similar to the TimedBuffer flusher thread.
       It (they) needs to not being slowed down by anything in order to work as expected and I've put     
       several checks that will be triggered otherwise. 
       If we have already something similar that I can reuse I will do it for sure.
    
    The only reason why we don't use Scheduled Executor at the Timedbuffer is because we use NanoSeconds intervals.. what's not good for the Executor.
    
    
    You already create a ScheduledExecutor... if you need your own executor, still use the component which encapsulates that.. if you can reuse one from the pool.. (It seems you can).. you can just pass in the argument.


---

[GitHub] activemq-artemis issue #1576: ARTEMIS-1447 JDBC NodeManager to support JDBC ...

Posted by franz1981 <gi...@git.apache.org>.
Github user franz1981 commented on the issue:

    https://github.com/apache/activemq-artemis/pull/1576
  
    @clebertsuconic I probably need to do just a little change on that component (ie: customize the initial delay) but the implementation now is simpler to be read/maintained. It was a good suggestion :)


---

[GitHub] activemq-artemis issue #1576: ARTEMIS-1447 JDBC NodeManager to support JDBC ...

Posted by clebertsuconic <gi...@git.apache.org>.
Github user clebertsuconic commented on the issue:

    https://github.com/apache/activemq-artemis/pull/1576
  
    @mtaylor @franz1981 I know there are JDBCDriver whose responsibility is to only manage connection pools. Wildfly provides one... I bet there are JDBCDriver that will act like a pool.. Hence I was a bit concerned we were implementing our own pool (disclaimer.. I didn't look at Franz's last update... just saying why I was a bit concerned about the pooling).


---