Open Source RDBMS - Seamless, Scalable, Stable and Free

한국어 | Login |Register

author
message
[Level:0]penguin

Post subject: Script lose connection with cubrid broker.

registered: 05/31/2011

IP: *.71.42.216

views: 79

Hi everybody. Sorry for my english.
I don't know, how it's work. But when i use long time connection to database with php. Cubrid (may be cubrid extension for php?) drop connection and all queries not work.

You can reproduce this by install cubrid, add php extension, create database and run next script


<?php

set_time_limit(0);
$user = "dba";
$password = "1111";
$host_ip = "localhost";
$host_port = 33000;
$db_name = "test";

$count_of_units = 1000000;

if (!($con = cubrid_connect($host_ip, $host_port, $db_name, $user, $password)))
{
echo 'Connetion error';
echo cubrid_error_msg();
exit;
}
for($i = 1; $i <= $count_of_units; $i++)
{
$rnd = rand(1,1000);
$req = cubrid_execute($con, "insert into tbl_test (`some`) values ({$rnd})");
if($req)
{
cubrid_commit($con);
}
else
{
echo 'Bug: ';
echo cubrid_error_msg();
break;
}
}

cubrid_disconnect($con);


Table tbl_test structure in attachement.

After over 500000 queries connection freezes. I think, that is associated with some brokers' settings, but i not sure. I use all by default.

configuration 1:
windows, xampp 1.7.3, cubrid 3.0, php 5.3.x cubrid module from official site (vc6)
configuration 2:
linux, apache 2.3, php 5.3.3, cubrid 3.0, php cubrid module from pecl.

Quote
[Level:3]eye

# Post subject:Re: Script lose connection with cubrid broker.

profile

registered: 05/31/2011

IP: *.91.137.50

Hi Penguin,

I've installed Ubuntu 10.04 in VMware. Installed CUBRID 3.0, Apache2 (2.2.14), php5 (5.3.3), and CUBRID PHP using PECL. No other settings. Everything is by default.

Created "test" db, and "tbl_test" table. Created a PHP file with your code as it is (no modifications: 1,000,000 inserts).

On my machine your script execution is finished in 0.271672 seconds.

Even in cases when millions of operations are executed, the connection will not be lost neither by CUBRID nor by the CUBRID PHP Connector.

To check if your long script is still being executed, that is it hasn't been disconnected, try counting how many records are being inserted at that moment.

1. Open the CUBRID Manager.
2. Right click on your "tbl_test", and click on the "Select All" menu item. This will create and run the following query
select count(*) from "tbl_test";
3. Run the query as frequently as you want to see if your script is being executed.

- If you see that the number is increasing every time until it reaches 1,000,000 records, then your PHP script is working correctly and is adding the new records.
- If you see that the number is not growing any more and didn't reach 1,000,000, then something is wrong. In this case, let me know and I will try to look at other reasons.

Quote
[Level:0]penguin

# Post subject:Re: Script lose connection with cubrid broker.

profile

registered: 05/31/2011

IP: *.71.41.174

"eye"...
Hi Penguin,
...
3. Run the query as frequently as you want to see if your script is being executed.

- If you see that the number is increasing every time until it reaches 1,000,000 records, then your PHP script is working correctly and is adding the new records.
- If you see that the number is not growing any more and didn't reach 1,000,000, then something is wrong. In this case, let me know and I will try to look at other reasons.


Hi. Do you create tbl_test like that?

create TABLE tbl_test(
`id` BIGINT AUTO_INCREMENT PRIMARY KEY,
`data` BIGINT
);

Quote
[Level:0]penguin

# Post subject:Re: Script lose connection with cubrid broker.

profile

registered: 05/31/2011

IP: *.71.41.174

Hi, eye. I resolve my issue :) Thank you for reply.

i use next code instead my previous version.

$req = cubrid_prepare($con, "insert into tbl_test (`some`) values (?)");
for($i = 1; $i <= $count; $i++)
{
$rnd = rand(1,1000);
$res = cubrid_bind($req,1,$rnd);
$res = cubrid_execute($req);
if($req)
{
cubrid_commit($con);
}
else
{
echo 'Error: ';
echo cubrid_error_msg();
break;
}
}

And all works fine.
Yes. I use default configuration of cubrid. (version 3.0 on windows and linux).

Quote




You are either using a very old browser or a browser that is not supported.
In order to browse cubrid.org you need to have one of the following browsers:



Internet Explorer: Mozilla Firefox: Google Chrome: