MySQL Forums
Forum List  »  NDB clusters

ejabberd + MySQL Cluster ERROR HASH ON PREFIX
Posted by: Jeffrey Rogiers
Date: November 14, 2006 09:46AM

Hello,

I have been working on moving ejabberd to a MySQL ndbcluster based database. Unfortunately there is a specific problem with getting this to work properly.

The mysql.sql the comes from the ejabberd source to create the rosterusers table as such:

CREATE TABLE rosterusers (
username varchar(250) NOT NULL,
jid varchar(250) NOT NULL,
nick text,
subscription character(1) NOT NULL,
ask character(1) NOT NULL,
server character(1) NOT NULL,
subscribe text,
type text
) TYPE=NDBCLUSTER CHARACTER SET utf8;

CREATE UNIQUE INDEX i_rosteru_user_jid USING HASH ON rosterusers(username(75), jid(75));
CREATE INDEX i_rosteru_username USING HASH ON rosterusers(username);
CREATE INDEX i_rosteru_jid USING HASH ON rosterusers(jid);

In order to use cluster the TYPE has to be set to NDBCLUSTER instead of InnoDB.

The first UNIQUE INDEX "i_rosteru_user_jid" throws an error (1089).

This is the given reason from the MySQL dev team on a very similar situation.
http://forums.mysql.com/read.php?25,15369,15498#msg-15498

-------
Harrison Fisk (MySQL AB) wrote:

Hi,

As the error message indicates and as [dev.mysql.com] also mentions, Cluster does not support indexes on prefixes of columns. So you can not create a unique on the first 25 characters. As you indicated the 32 works because that is the entire column width (not a prefix).

The reason why this doesn't matter is because the UNIQUE is implemented as a hashed value. That means it will take up the same width in the index regardless of how many characters you use in it. Even non-unique indexes contain a direct pointer to the data rather than a copy since it is a t-tree.

Harrison Fisk, Trainer and Consultant
MySQL AB, www.mysql.com
------

So in order to work around this I have tried playing around with the UNIQUE and prefixing, but unfortunately it does not work properly. Eventually the rosters will stop working.

So given the following situation I am stuck at a point where i am forced to use a table as InnoDB, and i have to make all ejabberd nodes connect to one specific database instead of connecting to their own mysql cluster api node.

If anyone could help me out, it would be greatly appreciated.

Thanks,
Jeffrey R.



Edited 1 time(s). Last edit at 11/14/2006 09:46AM by Jeffrey Rogiers.

Options: ReplyQuote


Subject
Views
Written By
Posted
ejabberd + MySQL Cluster ERROR HASH ON PREFIX
2302
November 14, 2006 09:46AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.