On Tue, 2013-12-17 at 17:28 -0500, Alex Vandiver wrote:
> This lies firmly in the domain of having to debug MySQL and the SphinxSE
> plugin, and not in debugging RT itself.  From recent testing locally,
> using 127.0.0.1 instead of localhost works acceptably.

I have confirmed that this is a bug in sphinxsearch.  mysql 5.5.15 and
above removed a codepath that SphinxSE was using to do name resolution,
and the re-implementation of it that SphinxSE uses could never have
worked.

The work-around is to use an IP address (rather than a hostname like
localhost) in the sphinx:// URL that rt-setup-fulltext-index prompts
for.  Alternately, the two attached patches can be applied to the
storage/sphinx/ directory.

The issue has been reported to sphinxsearch as bug 1815.  RT may work
around this issue in a future release by defaulting to suggesting
127.0.0.1 instead of localhost when running on MySQL 5.5.
 - Alex
>From 21770e15fa8667177b79ae8f5cd8de67ebd44b28 Mon Sep 17 00:00:00 2001
From: Alex Vandiver <a...@chmrr.net>
Date: Thu, 19 Dec 2013 01:18:43 -0500
Subject: [PATCH 1/2] getaddrinfo returns 0 on success

---
 mysqlse/ha_sphinx.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mysqlse/ha_sphinx.cc b/mysqlse/ha_sphinx.cc
index 06c8610..8305519 100644
--- a/mysqlse/ha_sphinx.cc
+++ b/mysqlse/ha_sphinx.cc
@@ -2121,7 +2121,7 @@ int ha_sphinx::Connect ( const char * sHost, ushort uPort )
 #if MYSQL_VERSION_ID>=50515
 			struct addrinfo *hp = NULL;
 			tmp_errno = getaddrinfo ( sHost, NULL, NULL, &hp );
-			if ( !tmp_errno || !hp || !hp->ai_addr )
+			if ( tmp_errno || !hp || !hp->ai_addr )
 			{
 				bError = true;
 				if ( hp )
-- 
1.8.5

>From 204e78173db262d2ba73555ed277f0908a3fc568 Mon Sep 17 00:00:00 2001
From: Alex Vandiver <a...@chmrr.net>
Date: Thu, 19 Dec 2013 01:19:20 -0500
Subject: [PATCH 2/2] Copy out the correct part of the addrinfo response

Merely copying starting at the ai_addr of the addrinfo is incorrect; for
the presumed sockaddr_in value stored in ai_addr, the first bytes are
generally the family and port, not the in_addr.

Dereference to the in_addr out explicitly, and copy that.
---
 mysqlse/ha_sphinx.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mysqlse/ha_sphinx.cc b/mysqlse/ha_sphinx.cc
index 8305519..d6ef94b 100644
--- a/mysqlse/ha_sphinx.cc
+++ b/mysqlse/ha_sphinx.cc
@@ -2148,7 +2148,7 @@ int ha_sphinx::Connect ( const char * sHost, ushort uPort )
 			}
 
 #if MYSQL_VERSION_ID>=50515
-			memcpy ( &sin.sin_addr, hp->ai_addr, Min ( sizeof(sin.sin_addr), (size_t)hp->ai_addrlen ) );
+			memcpy ( &sin.sin_addr, &((struct sockaddr_in *)hp->ai_addr)->sin_addr, sizeof(sin.sin_addr) );
 			freeaddrinfo ( hp );
 #else
 			memcpy ( &sin.sin_addr, hp->h_addr, Min ( sizeof(sin.sin_addr), (size_t)hp->h_length ) );
-- 
1.8.5

Reply via email to