Month: July 2013

Spring autowire values in @Controller

The Java Spring framework allows you to annotate classes via the _@Controller _annotation. This allows you to maps requests and handle them via a MVC implementation. These classes can be detected automatically via a:

<context:component-scan base-package="example.class" />

The downside of this approach is that the values cannot be set anymore via a tag, because the class is already constructed. In order to still be able to set values in the class use the @Value annotation in the attribute fields of the class.

Leave a Comment

MySQL skip replication

Replication in MySQL is a useful tool to build a fast and reliable database infrastructure. But replication can go wrong, which leaves the MySQL slave unable to execute the queued query. This halts the entire replication process, replication commands after that are also not executed.

The cause for the replication problem can be determined by logging in and the slave and executing the command:

SHOW SLAVE STATUS\G

This shows the following output if replication is running correct, the important attribute is the Slave_IO_State:

mysql> show slave status\G
    *************************** 1. row ***************************
                 Slave_IO_State: Waiting for master to send event
                    Master_Host: 127.0.0.1
                    Master_User: replication
                    Master_Port: 3306
                  Connect_Retry: 60
                Master_Log_File: mysql-bin.000045
            Read_Master_Log_Pos: 53443450
                 Relay_Log_File: mysqld-relay-bin.001454
                  Relay_Log_Pos: 53443587
          Relay_Master_Log_File: mysql-bin.000045
               Slave_IO_Running: Yes
              Slave_SQL_Running: Yes
                Replicate_Do_DB:
            Replicate_Ignore_DB: mysql
             Replicate_Do_Table:
         Replicate_Ignore_Table:
        Replicate_Wild_Do_Table:
    Replicate_Wild_Ignore_Table:
                     Last_Errno: 0
                     Last_Error:
                   Skip_Counter: 0
            Exec_Master_Log_Pos: 53443450
                Relay_Log_Space: 53443587
                Until_Condition: None
                 Until_Log_File:
                  Until_Log_Pos: 0
             Master_SSL_Allowed: No
             Master_SSL_CA_File:
             Master_SSL_CA_Path:
                Master_SSL_Cert:
              Master_SSL_Cipher:
                 Master_SSL_Key:
          Seconds_Behind_Master: 0
    1 row in set (0.00 sec)

It may be that a certain CRUD command cannot be executed, this will be displayed in the same attribute that now shows everything is okay. After examination you may decide to skip that action, because it is not important or you decide to execute it manually. Execute the following command to skip 1 command:

SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1; START SLAVE;

For more information on replication and other skipping possibilities read this article on ducea.com.

Leave a Comment