Bugzilla – Bug 4226
Problem with multiple instances of RFT accessing the same database
Last modified: 2006-10-03 10:41:20
You need to log in before you can comment on or make changes to this bug.
When multiple instances of RFT attempt to use the same database, duplicate key errors arise. Tables are used to hold counters that act as primary keys for RFT transfers. The methods, getNextTransferId and getNextRequestId which are in ReliableFileTransferDbAdapter.java, read, increment and update these tables. When multiple instances access the same database, these methods become a critical section. The patch being submitted takes advantage of databases inherent locking mechanisms. Transaction management and table locking have been added to the methods in question. By doing this, the instance that reads from the table holds an exclusive lock on the table until it is done updating. The file rft_schema_mysql.sql has also been modified. By default, MySQL creates tables using an engine that does not allow for transactions and table locking in the traditional sense. The tables’ requestid and transferid need to be created with the InnoDB engine, which allows for traditional locking and transactions. This patch has been tested with both PostgreSQL and MySQL. It appears that the current use of Derby will not allow for the above technique. The Derby server is being started in embedded mode and this mode allows only a single instance to connect.
Created an attachment (id=853) [details] Patch for fixing multiple instances of RFT accessing the same database
Patrick thanks for the patch. I will have to take a look how this breaks support for derby since we are moving towards having RFT use derby by default. I will try and isolate the code so that it won't break when derby is used
Patrick are you trying to have more than one RFT service access/use a single database instance? This is not supported with the present code base as the restart information of a RFT request is stored in the database instance too. So the services will be restarting each other instances. Right now, the one RFT deployment should correspond to one database instance. The patch you provided will probably address one change that needs to go in in order for multiple RFT deployments to use a single db, but i think there are more places. We do have a plan to add support for this in future by using container-id in the db schema to make sure restarts work fine across multiple containers.
Created an attachment (id=879) [details] Changes to add a unique container ID to each request. A new field needs to be added to the request table: containerID. This field will hold a unique identifier for each row based on the container that inserts the row into the database. This patch adds the code to insert the value and also use the value in selecting correct rows on a restart.