-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SNOW-1887475: curl_easy_perform() failed: Out of memory #410
Comments
hi - thanks for raising this issue. I remember typing a response but somehow now it's gone? Anyhow. This issue looks to be similar to #318 and as of such, I believe that one could be followed for updates if/when there will be any, for this enhancement effort.
Can you please see if this is relevant to your issue ? If so, I would suggest marking this one as closed and follow 318 instead. |
Hi. Thanks for looking at this. I can see that it could be related so I'll close this as duplicate and hopefully 318 will fix the issue. |
based on
i'm reopening this issue to investigate why we still OOM even with subset result set. |
Hi, the PHP dev team took a look into this issue. For now, short version is: it looks like an application issue and not with the driver. Long version is, given from shanedale's example :
it looks like the memory was used for the array which stored the query result returned from the driver. There seems to be indeed a little bit (1KB) of memory leak on the driver side, but it's not significant enough to be the root cause for the issue which is described here, and to crash the whole process with OOM. Then they did a local test, using Here's the code used for the test: for ($i = 1; $i <= 20; $i++) {
try {
echo 'Memory usage before snowflake pdo creation: ' . memory_get_usage() . "\n";
$pdo = new PDO($dsn, $user, $password);
$pdo->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
$query = 'SELECT * FROM SNOWFLAKE_SAMPLE_DATA.TPCH_SF1000.ORDERS LIMIT 20000';
echo 'Memory usage before snowflake retrieval: ' . memory_get_usage() . "\n";
$stmt = $pdo->prepare($query);
$stmt->execute();
$records = $stmt->fetchAll(PDO::FETCH_ASSOC);
echo 'Memory usage after snowflake retrieval: ' . memory_get_usage() . " number of records: " . sizeof($records) . "\n";
} catch (PDOException $e) {
error_log($e->getMessage());
echo "Snowflake Connection failed: " . $e->getMessage() . "\n";
} finally {
if ($stmt) {
$stmt = null;
echo 'Memory usage after stmt cleaning: ' . memory_get_usage() . "\n";
}
if ($pdo) {
$pdo = null;
echo 'Memory usage after pdo cleaning: ' . memory_get_usage() . "\n";
}
if ($records) {
$records = null;
echo 'Memory usage after array cleaning: ' . memory_get_usage() . "\n";
}
}
} and its result:
we can see that even after the 20th loop, memory usage is almost the same as it was initally ( Hope this helps somewhat. |
While I can't provide any debug output at this time... I did encounter the exact same The error would occur intermittently on queries returning one result as well as queries returning tens of thousands of results. I think I can reproduce but eventually had to move on to get it "working" again. Driver was built with several different PHP versions over time (though I realize 8.4. support isn't officially in 3.0.2): 8.3.14, 8.3.15, 8.4.0, 8.4.1, and 8.4.2. All on Debian Bullseye. Given that driver version 3.0.3 had the following changes in the release notes:
It could be any of these that caused the issue. It looks like the previous version of curl in the driver was 8.7.1. My "fix" was to revert to driver version 3.0.2. The error went away (until I have to go to 3.0.3 or later). Maybe this helps? Thank you for supporting this driver. |
I'll have to try reverting to a previous version as logically I can't see the queries being a problem. |
this is brand new information folks which wasn't available until now; that it only happens with 3.0.3 and not the previous version. Thank you for pointing it out. We'll look into it. |
I've changed my version to 3.0.2 and I've not seen the error again. |
@cjsfj @android-rewstar and other folks who might be seeing this issue. The dev team is unable to reproduce this issue for now.
Thank you in advance! |
Hi. I'm having a problem with curl I think. I have the following problem. The query is large and I can't share it here. I've been building the driver locally so I can test changes to the driver if needed. The problem happens on my windows dev machine and on the php:8.2-apache docker container that it runs on so it's not limited to an operating system. Thanks.
What version of PDO/PHP driver are you using?
Snowflake PHP PDO Driver: 8.2.18-3.0.3
PHP 8.2.27 (same issue on Windows and Linux)
What operating system and processor architecture are you using?
Snowflake C/C++ API: 1.1.0, OS: Windows, OS Version: 10.0-x86_64
What version of C/C++ compiler are you using?
Not sure, VS installer says 16.11.42 for the
What did you do?
I was running a large query. The query works fine but every so often it fails. It seems to work the first time.
this is the PHP, the connection string includes a private key file location. I've tried a few different ways of writing this php and they all result in the same error.
$db = new PDO($connectionstring, $username, "");
$db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false);
$statement = $db->prepare($sql);
$statement->execute($data);
$results = [];
foreach ($statement as $i => $row) {
$results[] = $row;
}
$statement->closeCursor();
What did you expect to see?
No error and query results
Can you set logging to DEBUG and collect the logs?
2025-01-13 08:59:41.129 INFO C client.c 841: Snowflake C/C++ API: 1.1.0, OS: Windows, OS Version: 10.0-x86_64
2025-01-13 08:59:41.129 INFO C client.c 489: Connecting to GLOBAL Snowflake domain
2025-01-13 08:59:41.129 DEBUG C client.c 518: application name: PDO
2025-01-13 08:59:41.129 DEBUG C client.c 519: application version: 8.2.18-3.0.3
2025-01-13 08:59:41.129 DEBUG C client.c 520: authenticator: snowflake_jwt
2025-01-13 08:59:41.129 DEBUG C client.c 521: user: ****
2025-01-13 08:59:41.129 DEBUG C client.c 522: password: ****
2025-01-13 08:59:41.129 DEBUG C client.c 524: priv_key_file: ****
2025-01-13 08:59:41.129 DEBUG C client.c 525: jwt_timeout: 60
2025-01-13 08:59:41.129 DEBUG C client.c 526: jwt_cnxn_wait_time: 10
2025-01-13 08:59:41.129 DEBUG C client.c 532: port: 443
2025-01-13 08:59:41.129 DEBUG C client.c 534: region: (null)
2025-01-13 08:59:41.129 DEBUG C client.c 535: database: ****
2025-01-13 08:59:41.129 DEBUG C client.c 536: schema: ****
2025-01-13 08:59:41.129 DEBUG C client.c 537: warehouse: ****
2025-01-13 08:59:41.129 DEBUG C client.c 538: role: ****
2025-01-13 08:59:41.129 DEBUG C client.c 539: protocol: https
2025-01-13 08:59:41.129 DEBUG C client.c 540: autocommit: true
2025-01-13 08:59:41.129 DEBUG C client.c 541: insecure_mode: false
2025-01-13 08:59:41.129 DEBUG C client.c 542: ocsp_fail_open: false
2025-01-13 08:59:41.129 DEBUG C client.c 543: timezone: (null)
2025-01-13 08:59:41.129 DEBUG C client.c 544: login_timeout: 300
2025-01-13 08:59:41.129 DEBUG C client.c 545: network_timeout: 0
2025-01-13 08:59:41.129 DEBUG C client.c 546: retry_timeout: 300
2025-01-13 08:59:41.129 DEBUG C client.c 547: retry_count: 7
2025-01-13 08:59:41.129 DEBUG C client.c 548: qcc_disable: false
2025-01-13 08:59:41.129 DEBUG C client.c 549: include_retry_reason: true
2025-01-13 08:59:41.133 DEBUG C connection.c 696: URL: ****
2025-01-13 08:59:41.238 ERROR C http_perform.c 403: curl_easy_perform() failed: Out of memory
2025-01-13 08:59:41.238 ERROR C client.c 970: No response
2025-01-13 08:59:41.238 DEBUG PDO snowflake_driver.c 45: file=ext\pdo_snowflake\snowflake_driver.c line=821
2025-01-13 08:59:41.238 ERROR PDO snowflake_driver.c 52: connection error
2025-01-13 08:59:41.238 ERROR PDO snowflake_driver.c 56: error code: 240012
2025-01-13 08:59:41.238 ERROR PDO snowflake_driver.c 71: sqlstate: 08001, msg: curl_easy_perform() failed: Out of memory
2025-01-13 08:59:41.238 ERROR PDO snowflake_driver.c 74: Failed to allocate DBH
The text was updated successfully, but these errors were encountered: