Mark Needham

Thoughts on Software Development

Neo4j Backup: java.lang.ClassCastException: org.jboss.netty.buffer.BigEndianHeapChannelBuffer cannot be cast to org.neo4j.cluster.com.message.Message

with 5 comments

(as Gabriel points out in the comments the ability to do a ‘HA backup’ doesn’t exist in more recent versions of Neo4j. I’ll leave this post here for people still running on older versions who encounter the error.)

When using Neo4j’s online backup facility there are two ways of triggering it, either by using the ‘single://‘ or ‘ha://‘ syntax and these behave slightly differently.

If you’re using the ‘single://’ syntax and don’t specify a port then it will connect to ‘6362’ by default:

./neo4j-backup -from single://192.168.1.34 -to /mnt/backup/neo4j-backup

If you’ve changed the backup port via the ‘online_backup_server’ property in conf/neo4j.properties you’ll need to set the port explicitly:

online_backup_server=192.168.1.34:6363
./neo4j-backup -from single://192.168.1.34:6363 -to /mnt/backup/neo4j-backup

If you’re using the ‘ha://’ syntax then the backup client joins the HA cluster, works out which machine is the master and then creates a backup from that machine.

In order for the backup client to join the cluster it connects to port ‘5001’ by default:

./neo4j-backup -from ha://192.168.1.34 -to /mnt/backup/neo4j-backup

If you’ve changed the ‘ha.cluster_server’ property then you’ll need to set the port explicitly:

ha.cluster_server=192.168.1.34:5002
./neo4j-backup -from ha://192.168.1.34:5002 -to /mnt/backup/neo4j-backup

A mistake that I made when first using this utility was to use the ‘ha://’ syntax with the backup port. e.g.

./neo4j-backup -from ha://192.168.1.34:6362 -to /mnt/backup/neo4j-backup

If you do this you’ll end up with the following exception:

2014-01-19 19:24:30.842+0000 ERROR [o.n.c.c.NetworkSender]: Receive exception:
java.lang.ClassCastException: org.jboss.netty.buffer.BigEndianHeapChannelBuffer cannot be cast to org.neo4j.cluster.com.message.Message
	at org.neo4j.cluster.com.NetworkSender$NetworkMessageSender.messageReceived(NetworkSender.java:409) ~[neo4j-cluster-2.0.0.jar:2.0.0]
	at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:268) ~[netty-3.6.3.Final.jar:na]
	at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:255) ~[netty-3.6.3.Final.jar:na]
	at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:88) ~[netty-3.6.3.Final.jar:na]
	at org.jboss.netty.channel.socket.nio.AbstractNioWorker.process(AbstractNioWorker.java:107) ~[netty-3.6.3.Final.jar:na]
	at org.jboss.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:312) ~[netty-3.6.3.Final.jar:na]
	at org.jboss.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:88) ~[netty-3.6.3.Final.jar:na]
	at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:178) ~[netty-3.6.3.Final.jar:na]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_45]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_45]
	at java.lang.Thread.run(Thread.java:744) [na:1.7.0_45]

Let me know in the comments if any of this doesn’t make sense. There are lots of other examples to follow on neo4j-backup’s man page in the manual as well.

Be Sociable, Share!

Written by Mark Needham

January 19th, 2014 at 7:29 pm

Posted in neo4j

Tagged with

  • Pingback: Neo4j Backup: Store copy and consistency check at Mark Needham

  • Gabriel Deak

    Hi there, we have found your post and have a question.
    You said ./neo4j-backup -from ha://192.168.1.34 -to /mnt/backup/neo4j-backup will detect which cluster node is the master. Firstly, the neo4j documentation does not mention this method. Second, we have tested this and it seems the script does not detect the master, it just runs a backup oh itself. Third, you say port 5001 is used for this. We were not able to run the script until we configure the following: online_backup_enabled=true, online_backup_server=0.0.0.0:6362, this was part of the default config (default wad 127.0.0.1:6362), so it seems it is actually using port 6362.

    Any idea on this?

  • http://www.markhneedham.com/blog Mark Needham

    Hi,

    Yeh the behaviour of the backup tool has changed since I wrote this post so you have to choose a specific machine to backup from as you suggested. The HA approach has been removed.

    Cheers
    Mark

  • Gabriel Deak

    Thanks Mark. I guess your previous post should be amended in case somebody else tries to use the method mentioned. Is there a reason why the backup tool has been completely changed? It makes more sense to have this functionality, especially with a cluster being recommended.

  • http://www.markhneedham.com/blog Mark Needham

    @gabrieldeak:disqus it used to cause too many problems / confusion as the backup client would have to join the cluster and temporarily be a member for the duration of the backup. It was operationally simpler to remove the feature.