Skip to Content.
Sympa Menu

freetds - RE: AW: [freetds] connect problem to mssql 7.0

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "ZIGLIO Frediano" <Frediano.Ziglio AT vodafone.com>
  • To: "FreeTDS Development Group" <freetds AT lists.ibiblio.org>
  • Subject: RE: AW: [freetds] connect problem to mssql 7.0
  • Date: Fri, 12 Dec 2003 15:04:32 +0100

>
> Hi freddy,
>
> one other point could be e.g a false network configuration,
> do you hear something about this ?
>

No.


Just to sum up your problem.

You have following configuration:
- debian Linux
- apache 1.3.26
- PHP 4.3.4
- FreeTDS 0.62 (a recent snapshot, built with ./configure
--enable-msdblib)
- mssql 7.0 server

You have a PHP script like
-------
<?php
$sql_host="xxx.xxx.xxx.xxx:1433";
$sql_user="test";
$sql_pass="test";
$sql_name="test";

echo
"
<form method='post' action =
'".$HTTP_SERVER_VARS["PHP_SELF"]."'>
<input type='text' name='search'><br><br>
<input type='hidden' name='test' value='teste'>
<input type='submit' name='submit' value='test'>
</form>

";

if($HTTP_POST_VARS["test"] == "teste")
{
$db_conn = mssql_pconnect ($sql_host,$sql_user,$sql_pass) or die
("Could not connect to database: ".mssql_get_last_message());


mssql_select_db ($sql_name, $db_conn) or die ("Could not select
database: ".mssql_get_last_message());

$sql = "select a.C003 as Name , b.C052 as Ort, b.C019 as
Telefon1, b.C020 as Telefon2, a.C002 as kundennr
from T0550203 a left outer join
T0510203 b on a.C002 = b.C001 where a.C003 like
'".$HTTP_POST_VARS["search"]."%' order by a.C003";


$query_result = mssql_query ($sql,$db_conn) or die ("query
faild: ".mssql_get_last_message());


while ($result = mssql_fetch_array($query_result)){

echo $result["Name"]."<br>";

}


}

?>
-------

TDSDUMP reports this

-------
pid: 11842:2003-12-09 11:16:32 processing row. column size is 11
pid: 11842:2003-12-09 11:16:32 clearing column 0 NULL bit
pid: 11842:2003-12-09 11:16:32 leaving dbnextrow() returning -1
pid: 11842:2003-12-09 11:16:32 dbdatlen() type = 39
pid: 11842:2003-12-09 11:16:32 leaving dbdatlen() returning 11
pid: 11842:2003-12-09 11:16:32 dbdatlen() type = 39
pid: 11842:2003-12-09 11:16:32 leaving dbdatlen() returning 11
pid: 11842:2003-12-09 11:16:32 inside dbnextrow()
pid: 11842:2003-12-09 11:16:32 processing row tokens. marker is fd
pid: 11842:2003-12-09 11:16:32 leaving dbnextrow() returning -2
pid: 11842:2003-12-09 11:16:38 UNIMPLEMENTED dbsetlogintime()
pid: 11842:2003-12-09 11:16:38 UNIMPLEMENTED dbsettime()
pid: 11842:2003-12-09 11:16:38 UNIMPLEMENTED dbsetmaxprocs()
-- old PID
-- new PID
pid: 11846:2003-12-09 11:16:43 UNIMPLEMENTED dbsetlogintime()
pid: 11846:2003-12-09 11:16:43 UNIMPLEMENTED dbsettime()
pid: 11846:2003-12-09 11:16:43 UNIMPLEMENTED dbsetmaxprocs()
pid: 11846:2003-12-09 11:16:49 UNIMPLEMENTED dbsetlogintime()
pid: 11846:2003-12-09 11:16:49 UNIMPLEMENTED dbsettime()
pid: 11846:2003-12-09 11:16:49 UNIMPLEMENTED dbsetmaxprocs()
pid: 11846:Sending packet @ 2003-12-09 11:16:49
0000 01 01 00 18 00 00 01 00 75 00 73 00 65 00 20 00 |........u
.s.e. .|
0010 45 00 4c 00 42 00 45 00 |E.L.B.E.|


pid: 11846:TDS: Write failed in tds_write_packet
Error: 104 (Connection reset by peer)
pid: 11846:2003-12-09 11:16:49 inside tds_process_default_tokens()
marker is 0
pid: 11846:2003-12-09 11:16:49 leaving tds_process_default_tokens()
connection dead
pid: 11846:2003-12-09 11:16:49 inside tds_process_default_tokens()
marker is 0
pid: 11846:2003-12-09 11:16:49 leaving tds_process_default_tokens()
connection dead
pid: 11846:2003-12-09 11:16:49 inside tds_process_default_tokens()
marker is 0
pid: 11846:2003-12-09 11:16:49 leaving tds_process_default_tokens()
connection dead
pid: 11846:2003-12-09 11:16:49 inside tds_process_default_tokens()
marker is 0
pid: 11846:2003-12-09 11:16:49 leaving tds_process_default_tokens()
connection dead
--------------------

If you leave PHP inactive after some time (30 - 60 minute) PHP reports
following error

Fatal error: Maximum execution time of 40 seconds exceeded in mssql.php
on line 24

I don't understand if row 24 is mssql_select_db or mssql_query...
There are some things I don't understand:
- why cannot I see a connection from second PID ? Perhaps log is not
complete ?
- why don't dblib detect connection broken and does not return to script
?

I checked PHP source (mssql_query) and seems correct...

I think that this happen
- You execute a script on first process (pid 11842)
- after a while apache start another project and close first connection
- another script is run
- PHP opens a new connection but fails.. why? And why does it keep
going?

I don't understand. I noted that dbsetlogintime/dbsettime/dbsetmaxprocs
is near to "use ELBE" query...
Also there are two dbsetlogintime/dbsettime/dbsetmaxprocs sequences with
a small delay (6 seconds)...
I'll check who calls these functions and why there is no connection...

Mmm... looking at this function

int
tds_do_until_done(TDSSOCKET * tds)
{
int marker, rows_affected = 0;

do {
marker = tds_get_byte(tds);
if (marker == TDS_DONE_TOKEN) {
tds_process_end(tds, marker, NULL);
rows_affected = tds->rows_affected;
} else {
tds_process_default_tokens(tds, marker);
}
} while (marker != TDS_DONE_TOKEN);

return rows_affected;
}

If connection get broken marker is always 0, tds_process_default_tokens
write some lines like
inside tds_process_default_tokens() marker is 0
leaving tds_process_default_tokens() connection dead
and then the loop goes on... causing an infinite loop... This should
solve timeout problem !!!
Strange broken connection however still remains...

freddy77




Archive powered by MHonArc 2.6.24.

Top of Page