Bugs item #2975433, was opened at 2010-03-23 20:47
Message generated for change (Comment added) made by sjoerd
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=482468&aid=2975433&group_id=56967

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Mapi
Group: Clients "stable"
Status: Open
>Resolution: Fixed
Priority: 5
Private: No
Submitted By: Stephen Benz (sbenz)
>Assigned to: Sjoerd Mullender (sjoerd)
Summary: PHP Native client occasionally truncates large result sets

Initial Comment:
mapi_read in the native php socket client assumes socket_read is going to 
actually return the chunk size that's requested.  While this does happen in 
many cases, when there's a large result set or network latency only a portion 
of that read may happen.  This causes a limited number of rows to be returned, 
and other weird behavior.

Environment:
Linux, CentOS 5
PHP 5.1.6
MonetDB Nov 2009 (but verified the php code hasn't been fixed in Feb 2010)

Reproduction steps:
1. $res = monetdb_query("select * from largeTable;"); // where largeTable is a 
table with 500k+ rows, in our case
2.  Notice the result doesn't contain all the rows... the number is variable 
based on the connection to the db server (we run monetdb on another server, 
*not localhost*)

Fix:
in php_mapi.inc (function mapi_read()):
                $data = socket_read($socket, $chunk_size);
                // can't assume the read is going to give you the actual size 
you expect
                while(strlen($data) < $chunk_size)
                {
                        $data .= socket_read($socket, $chunk_size - 
strlen($data));
                }

and a few lines later:

                        if ( ($block = socket_read($socket, $chunk_size)) == 
FALSE) {
                                $last_error = 
socket_strerror(socket_last_error()); 
                                return FALSE;
                        }
                        while(strlen($block) < $chunk_size)
                        {
                                $block .= socket_read($socket, $chunk_size - 
strlen($block));
                        }



----------------------------------------------------------------------

>Comment By: Sjoerd Mullender (sjoerd)
Date: 2010-04-15 15:04

Message:
Thanks for the report and the fix.
I checked in a variant of your fix.  This should make it into the next
release.
Can you check whether my version works?

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=482468&aid=2975433&group_id=56967

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Monetdb-bugs mailing list
Monetdb-bugs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/monetdb-bugs

Reply via email to