-
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! |
We have been facing the exact same issue. It started to occur all of a sudden last week. We were using version 3.0.3 of the library. And the issue was kind of intermittent.
It was being thrown on this line: Downgrading the library to version 3.0.2 seems to have resolved the issue. |
hey @tvalenta1 thanks for your addition! Did you experience the issue immediately after upgrading to 3.0.3, or your application could run just fine for a while, before you started seeing this kind of issue ? If the latter, do you have an estimation how long the application could run on 3.0.3 after upgrade + restart, before you started seeing this issue? Also @android-rewstar @cjsfj if you can perhaps provide input; since you downgraded to 3.0.2 for a while now. Are you still free of this issue after the downgrade? |
Hello @sfc-gh-dszmolka , version 3.0.2 seems to be running fine for us for almost a week already. The issue has not appeared since we downgraded. |
I was using very old version and upgraded to version 3.1.0, then starting from 29th of Jan 2025 I started seeing the |
Hi @sfc-gh-dszmolka . We've not seen any errors since downgrading to 3.0.2. |
Hi all, thank you for all your inputs, really helpful ! On a side note for you who's still using PHP 7.3 - anything under PHP 8.0 is not supported by the driver anymore (even with 3.0.2, so interesting it's stable with PHP 7.3.). |
One more thing, just to be sure we're looking at the right things. If anyone could provide details on
that could be also very helpful; just wanted to cover this angle in the investigation in case there's some server-side change which might not play well with the new libsnowflakeclient which is under the PHP driver from 3.0.3. |
I've upgraded to 3.1.0 mainly because I upgraded PHP version to 8.4 |
We are encountering this issue on version 3.0.3 with PHP 8.2.27 (using the Docker image Here’s the chronology of events:
This might be a red herring, but it seems that something may have changed on the Snowflake side, perhaps related to a new load balancer or another infrastructure component causing these issues. update: |
hi all - there's some update.
If you're not comfortable sharing logs here, please raise an official Support case and mention you're here because of this issue, #410. Then you can share the logs privately with Snowflake Support. In addition to that, thank you who already shared the PHP versions. Since as mentioned earlier, there's a suspicion into a correlation with a Snowflake server-side change, if you could please also let us know of the deployment of your Snowflake account, that would be greatly helpful. If you don't know the deployment, perhaps the easiest way is to run |
In addition to the previous message, and that anyone providing their Snowflake deployment would be still helpful.. dev team made another fix after looking a bit more into the issue. The current suspect is error handling with libcurl, which was changed with the underlying libsnowflakeclient bump with 3.0.3 and up. Library has been reverted to the one which is used in 3.0.2 , plus the aforementioned other fix for the small memory leak - #421 If any of you has some time to try it, let us know please; your feedback is important. |
Just wanted to mention, we installed |
Appreciate everyone submitting new reports here! Could any of you please share the Snowflake deployment (output of Hence these questions:
and of course if any of you has time to collect data as mentioned here [link] that would be immensely helpful for the dev team. Appreciate the help, everyone! |
For a little extra context in case it helps, in our situation where we see this issue we are using Laravel with long-running processes handling job queues. That said the connection is re-established and destroyed as needed (i.e. it's not created and then held in memory for the life of the process), and we are not using persistent connections. It's my theory the problem has to do with recreating the connection repeatedly, in case it helps. We are using PHP 8.1. |
We're also in We started seeing this only since last Tuesday, but been on 3.1 since Feb 4. |
Hi. We're in AZURE_UKSOUTH running on PHP 8.2.27 |
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: