Skip to content

Conversation

@sfc-gh-ext-simba-jy
Copy link
Collaborator

@sfc-gh-ext-simba-jy sfc-gh-ext-simba-jy commented Mar 8, 2025

No description provided.

{
CXX_LOG_TRACE("sf::HeartbeatBackrgound::renew_session_sync::Failed to renew session");
stop_heart_beat_for_this_session(sf);
return SF_BOOLEAN_FALSE;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should return the curl to the pool.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @sfc-gh-dstempniak, If you don’t mind, could you please elaborate on this? As far as I remember, the original return type of this function was void, and I only changed it to sf_bool for testing purposes. I’m not quite sure why we need to return the curl object here — could you clarify that?

snowflake_connect(sf);
std::this_thread::sleep_for(std::chrono::milliseconds(20000));
//Make sure renew_session_sync work well
*result = renew_session_sync(sf);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain/comment why do we sleep for 20s and why we call renew_session_sync?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn’t need to be 20 seconds. I updated it with 100 milliseconds. I used renew_session_sync to test the heartbeat with multiple connections

lib/connection.c Outdated

uint64 validate_client_session_keep_alive_heart_beat_frequency(int64 heart_beat_frequency)
{
int64 max = SF_DEFAULT_CLIENT_SESSION_ALIVE_HEARTBEAT_FREQUENCY;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we shouldn't use the default value to limit the heartbeat frequency. masterValidityInSeconds can be changed on server like here. If we get 60 from the server, we will set it to 900, which seems not good.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed this code to match the behavior of ODBC.

if (m_worker == NULL)
{
this->m_master_token_validation_time = connection->master_token_validation_time;
this->m_heart_beat_interval = connection->client_session_keep_alive_heartbeat_frequency;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think m_master_token_validation_time is never used.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since I removed validate_client_session_alive_heartbeat_frequency, I also removed m_heartbeat_interval and updated libsfclient to use m_master_token_validation_time to calculate the frequency.

}
else
{
if (connection->master_token_validation_time < this->m_master_token_validation_time)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we use m_heart_beat_interval for sleeping, we should recalculate it as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same as above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants