MySQL Forums
Forum List  »  Custom Storage Engines

Need help: Facing issues with MySQL UDF implementations
Posted by: Santosh Aitha
Date: August 10, 2012 03:54AM

Hi

I am trying to deply a MySQL cluster for in our telecome operating
system. I could see MySQl supports only events which can be scheduled
but I would like use events which can be posted by user as and when
required.

To implement this, I am trying to use MySQL UDF functions through which
I can open a socket and send a message to server running in my
application area. But I am facing some issues and when I call UDF
function from mysql server it is getting shutdown and dumping below
errors.

Can somebody help me to resolve the issue? Thanks


09:10:29 UTC - mysqld got signal 11 ;
This could be because you hit a bug. It is also possible that this
binary
or one of the libraries it was linked against is corrupt, improperly
built,
or misconfigured. This error can also be caused by malfunctioning
hardware.
We will try our best to scrape up some info that will hopefully help
diagnose the problem, but since we have already crashed,
something is definitely wrong and this may fail.

key_buffer_size=8388608
read_buffer_size=131072
max_used_connections=2
max_threads=151
thread_count=2
connection_count=2
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads =
337875 K bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

Thread pointer: 0x9538c10
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = ffffffffa7887390 thread_stack 0x30000
../bin/mysqld(my_print_stacktrace+0x34)[0x8474785]
../bin/mysqld(handle_fatal_signal+0x2f9)[0x834d311]
[0x110420]
../bin/mysqld(my_net_write+0xe7)[0x81d7d3b]
../bin/mysqld(_ZN8Protocol5writeEv+0x3e)[0x81dd100]
../bin/mysqld(_ZN11select_send9send_dataER4ListI4ItemE+0xd8)[0x821b1e2]
../bin/mysqld(_ZN4JOIN4execEv+0x336)[0x82602ba]
../bin/mysqld(_Z12mysql_selectP3THDPPP4ItemP10TABLE_LISTjR4ListIS1_ES2_jP8st_orderSB_S2_SB_yP13select_resultP18st_select_lex_unitP13st_select_lex+0x2a9)[0x8261fad]
../bin/mysqld(_Z13handle_selectP3THDP3LEXP13select_resultm+0x151)[0x825c021]
../bin/mysqld[0x824460a]
../bin/mysqld(_Z21mysql_execute_commandP3THD+0x616)[0x823f2a4]
../bin/mysqld(_Z11mysql_parseP3THDPcjP12Parser_state+0x1d7)[0x8245ce9]
../bin/mysqld(_Z16dispatch_command19enum_server_commandP3THDPcj+0x7f9)[0x823d355]
../bin/mysqld(_Z10do_commandP3THD+0x11d)[0x823c9fb]
../bin/mysqld(_Z24do_handle_one_connectionP3THD+0x162)[0x82e3764]
../bin/mysqld(handle_one_connection+0x2b)[0x82e3319]
/lib/libpthread.so.0[0x47b832]
/lib/libc.so.6(clone+0x5e)[0x3bb46e]

Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (9501218): select myfunc_client("127.0.0.1")
Connection ID (thread ID): 5
Status: NOT_KILLED

The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html
contains
information that should help you find out what is causing the crash.


Below is the UDF implementation. I am calling this function as below
from MySQL.

select myfunc_client("127.0.0.1");

int myfunc_client(UDF_INIT *initid __attribute__((unused)), UDF_ARGS
*argv,
char *is_null, char *error
__attribute__((unused)),char* message __attribute__((unused)))
{
int sockfd = 0, n = 0 ,rc;
char sendBuff[1024];
struct sockaddr_in serv_addr;
char in_addr[256];
char msg[256] = "hello, sending message, to server from UDF";
unsigned int length;

if((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
{
strcpy(message,"\n Error : Could not create socket \n");
return 1;
}

memset(&serv_addr, '0', sizeof(serv_addr));

serv_addr.sin_family = AF_INET;
serv_addr.sin_port = htons(2001);

length = sizeof(argv->lengths[0]);
if (length >= sizeof(in_addr))
length=sizeof(in_addr)-1;
memcpy(in_addr,argv->args[0],length);
in_addr[length]=0;

memset(sendBuff, '0',sizeof(sendBuff));
if(inet_pton(AF_INET, in_addr, &serv_addr.sin_addr)<=0)
{
strcpy(message,"\n inet_pton error occured\n");
return 1;
}
rc = connect(sockfd, (struct sockaddr *)&serv_addr,
sizeof(serv_addr));
strcpy(message,"\n Error : Connect rc=\n");
if( rc < 0)
{
strcpy(message,"\n Error : Connect Failed rc=\n");
return 1;
}
strcpy(message,"\nconected to server");
memset(msg, '0',sizeof(msg));
snprintf(sendBuff, sizeof(sendBuff), "%s\n",msg);
strcpy(message,"before writing\n");
write(sockfd, sendBuff, strlen(sendBuff));

if(n < 0)
{
strcpy(message,"\n Read error \n");
}
strcpy(message,"read completed\n");

return 0;
}



Thanks,
Santosh

Options: ReplyQuote


Subject
Views
Written By
Posted
Need help: Facing issues with MySQL UDF implementations
5241
August 10, 2012 03:54AM


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.