Uploaded image for project: 'Directory ApacheDS'
  1. Directory ApacheDS
  2. DIRSERVER-2113

Integrate the 'partition-plumber' into ApacheDS

    Details

    • Type: New Feature
    • Status: Resolved
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 2.0.0-M20
    • Fix Version/s: 2.0.0-M22
    • Component/s: None
    • Labels:
      None

      Description

      Kiran has developped a small tool that fix a corrupted JDBM database : the partition-plumber (see https://svn.apache.org/repos/asf/directory/sandbox/kayyagari/partition-plumber/).

      This is the only way we can get back on our feet when the database gets corrupted (if and only if the MasterTable is not itself corrupted, something that happens quite rarely).

      I suggest strongly we inject this smart tool in the server so that a user with a corrupted database can repair it by starting the server with a special option (something like apacheds -repair).

      That would save our users a lot of pain (like reloading the full database, assuming they have a recent backup...)

        Activity

        Hide
        elecharny Emmanuel Lecharny added a comment -

        Added. a 'repair' parameter can be passed to the UberJarMain class that will start the server after having tried to repair the indexes.

        Show
        elecharny Emmanuel Lecharny added a comment - Added. a 'repair' parameter can be passed to the UberJarMain class that will start the server after having tried to repair the indexes.
        Hide
        seelmann Stefan Seelmann added a comment -

        I wanted to integrate a "repair" action into Studio.

        I noticed that the UberjarMain.repair() method actually starts the server and then repairs the partition and then keeps the server running. I wonder why it is required to start the server before repairing the partitions. And if it's required I think it may be a good idea to stop the server afterwards. Otherwise I think it's confusing when calling repair but the server keeps running.

        Show
        seelmann Stefan Seelmann added a comment - I wanted to integrate a "repair" action into Studio. I noticed that the UberjarMain.repair() method actually starts the server and then repairs the partition and then keeps the server running. I wonder why it is required to start the server before repairing the partitions. And if it's required I think it may be a good idea to stop the server afterwards. Otherwise I think it's confusing when calling repair but the server keeps running.
        Hide
        elecharny Emmanuel Lecharny added a comment -

        We need to start the server in order to load the schema and the configuration (index declaration etc). I agree we should not start the full server (ie, the network layer, etc), and that we should stop the server at the end. My goal was to offer a way to get the server running after having been repaired, but it's probably a bit overkilling.

        Show
        elecharny Emmanuel Lecharny added a comment - We need to start the server in order to load the schema and the configuration (index declaration etc). I agree we should not start the full server (ie, the network layer, etc), and that we should stop the server at the end. My goal was to offer a way to get the server running after having been repaired, but it's probably a bit overkilling.
        Hide
        elecharny Emmanuel Lecharny added a comment -

        Actually, I think the code is wrong :

            public void repair( String instanceDirectory )
            {
                InstanceLayout layout = new InstanceLayout( instanceDirectory );
                
                // Creating ApacheDS service
                service = new ApacheDsService();
                
                try
                {
                    service.start( layout );
                }
                catch ( Exception e )
                {
                    return;
                }
        
                // Initializing the service
                try
                {
                    LOG.info( "Starting the service." );
                    service.repair( layout );
                    LOG.info( "Database repaired." );
                }
                catch ( Exception e )
                {
        ...
        

        should be :

            public void repair( String instanceDirectory )
            {
                InstanceLayout layout = new InstanceLayout( instanceDirectory );
                
                // Creating ApacheDS service
                service = new ApacheDsService();
                
                // Repairing the partitions
                try
                {
                    LOG.info( "Starting the service." );
                    service.repair( layout );
                    LOG.info( "Database repaired." );
                }
                catch ( Exception e )
                {
        ...
        
        Show
        elecharny Emmanuel Lecharny added a comment - Actually, I think the code is wrong : public void repair( String instanceDirectory ) { InstanceLayout layout = new InstanceLayout( instanceDirectory ); // Creating ApacheDS service service = new ApacheDsService(); try { service.start( layout ); } catch ( Exception e ) { return; } // Initializing the service try { LOG.info( "Starting the service." ); service.repair( layout ); LOG.info( "Database repaired." ); } catch ( Exception e ) { ... should be : public void repair( String instanceDirectory ) { InstanceLayout layout = new InstanceLayout( instanceDirectory ); // Creating ApacheDS service service = new ApacheDsService(); // Repairing the partitions try { LOG.info( "Starting the service." ); service.repair( layout ); LOG.info( "Database repaired." ); } catch ( Exception e ) { ...
        Hide
        seelmann Stefan Seelmann added a comment -

        Trunk looks a bit different (sysout instead of usage of logger).

        When I remove the "start" I get an NPE:

        java.lang.NullPointerException
        	at org.apache.directory.server.ApacheDsService.getDirectoryService(ApacheDsService.java:587)
        	at org.apache.directory.server.ApacheDsService.repair(ApacheDsService.java:251)
        	at org.apache.directory.server.UberjarMain.repair(UberjarMain.java:192)
        	at org.apache.directory.server.UberJarMainTest.repairTest(UberJarMainTest.java:364)
        

        Anyway, in Studio I'll call the action"Start and Repair" for now, later we can change it again.

        Show
        seelmann Stefan Seelmann added a comment - Trunk looks a bit different (sysout instead of usage of logger). When I remove the "start" I get an NPE: java.lang.NullPointerException at org.apache.directory.server.ApacheDsService.getDirectoryService(ApacheDsService.java:587) at org.apache.directory.server.ApacheDsService.repair(ApacheDsService.java:251) at org.apache.directory.server.UberjarMain.repair(UberjarMain.java:192) at org.apache.directory.server.UberJarMainTest.repairTest(UberJarMainTest.java:364) Anyway, in Studio I'll call the action"Start and Repair" for now, later we can change it again.
        Hide
        elecharny Emmanuel Lecharny added a comment -

        Ah, crap...

        I will have a look at why the start is necessary (which should not be...).

        Regarding the sysout vs log, it may be because I looked at teh 'Value' branch, not trunk.

        I'll get both issue fixed. Thanks for having added the action in Studio !

        Show
        elecharny Emmanuel Lecharny added a comment - Ah, crap... I will have a look at why the start is necessary (which should not be...). Regarding the sysout vs log, it may be because I looked at teh 'Value' branch, not trunk. I'll get both issue fixed. Thanks for having added the action in Studio !
        Hide
        elecharny Emmanuel Lecharny added a comment -

        Ok, the problem is that the SchemaManager is associated with the DirectoryService instance, which get created when we start the server.

        So the idea would be to start the server without starting the transport layer. That is somthing I can add to the existing code.

        Show
        elecharny Emmanuel Lecharny added a comment - Ok, the problem is that the SchemaManager is associated with the DirectoryService instance, which get created when we start the server. So the idea would be to start the server without starting the transport layer. That is somthing I can add to the existing code.
        Hide
        elecharny Emmanuel Lecharny added a comment -

        FTR, I have used System.out.println for the command line version (pretty much as the ApacheDS starting message we get). It's convenient in this case.

        Show
        elecharny Emmanuel Lecharny added a comment - FTR, I have used System.out.println for the command line version (pretty much as the ApacheDS starting message we get). It's convenient in this case.
        Hide
        elecharny Emmanuel Lecharny added a comment -

        I alsi think that would be valuable to have a repairAndStart method in UberMain.

        Show
        elecharny Emmanuel Lecharny added a comment - I alsi think that would be valuable to have a repairAndStart method in UberMain .

          People

          • Assignee:
            Unassigned
            Reporter:
            elecharny Emmanuel Lecharny
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development