Skip to content
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

DataStorm fixes for configuration, session retries, and more #3166

Merged
merged 4 commits into from
Nov 19, 2024

Conversation

pepone
Copy link
Member

@pepone pepone commented Nov 19, 2024

No description provided.

<property name="Topic.DiscardPolicy" default="Never" languages="cpp" />
<property name="Topic.Priority" default="0" languages="cpp" />
<property name="Topic.SampleCount" default="-1" languages="cpp" />
<property name="Topic.SampleLifetime" default="0" languages="cpp" />
Copy link
Member Author

Choose a reason for hiding this comment

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

Topic properties where not added before, but they are public and documented in

https://doc.zeroc.com/datastorm/latest/property-reference/datastorm-topic

I updated the docs to include -1 default for SampleCount this was missing in the docs.

@@ -517,7 +517,6 @@ SessionI::connected(SessionPrx session, const Ice::ConnectionPtr& connection, co
lock_guard<mutex> lock(_mutex);
if (_destroyed || _session)
{
assert(_connectedCallbacks.empty());
Copy link
Member Author

Choose a reason for hiding this comment

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

Removed unused _connectedCallbacks we never add any callbacks.

for (auto& t : _topics)
{
runWithTopics(t.first, [&](TopicI* topic, TopicSubscriber&) { topic->detach(t.first, shared_from_this()); });
runWithTopics(t.first, [id = t.first, self](TopicI* topic, TopicSubscriber&) { topic->detach(id, self); });
Copy link
Member Author

Choose a reason for hiding this comment

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

minor change, no need to call shared_from_this in the loop or capture everything by ref.

Copy link
Member

Choose a reason for hiding this comment

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

Could you declare self in the capture block to avoid an extra copy?

@@ -655,20 +650,17 @@ SessionI::retry(NodePrx node, exception_ptr exception)
}
}

if (node->ice_getEndpoints().empty() && node->ice_getAdapterId().empty())
// Cancel any pending retry task, before we start a new one below.
if (_retryTask)
Copy link
Member Author

Choose a reason for hiding this comment

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

Previous code only canceled the retry task when there is no endpoints. Here we are about to schedule a new task I think is clear to cancel any pending task.

@@ -678,16 +670,15 @@ SessionI::retry(NodePrx node, exception_ptr exception)
<< " (ms) for peer to reconnect";
}

// Schedule a timer to remove the session if the peer doesn't reconnect.
_retryTask = make_shared<IceInternal::InlineTimerTask>([self = shared_from_this()] { self->remove(); });
Copy link
Member Author

Choose a reason for hiding this comment

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

Here SessionI::remove would call retry again, and we schedule a new call to remove.

As far as I see we have and endless loop of calling retry to print this message and scheduling the remove call that just calls retry.

if (exception)
{
try
{
rethrow_exception(exception);
}
catch (const Ice::LocalException& ex)
catch (const std::exception& ex)
Copy link
Member Author

Choose a reason for hiding this comment

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

This is to match what we do above, when we handle what exceptions to retry.

is >> value;
return value;
}

Copy link
Member Author

Choose a reason for hiding this comment

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

unused after updating handling of configurations.

Comment on lines +73 to +76
if (value == "Never")
{
return DataStorm::DiscardPolicy::None;
}
Copy link
Member Author

Choose a reason for hiding this comment

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

We have this discrepancy, documented value is "Never", but the enum value is None.

Copy link
Member

Choose a reason for hiding this comment

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

I assume Never is the "right" choice here.

Copy link
Member Author

Choose a reason for hiding this comment

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

DiscardPolicy is part of the public API. User code can still set it manually using DiscardPolicy::None.

Should we rename DiscardPolicy::None to DiscardPolicy::Never?

Copy link
Member

Choose a reason for hiding this comment

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

Or parse both "Never" and "None" to DiscardPolicy::None?

Copy link
Member

Choose a reason for hiding this comment

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

I think it's preferable to just have one value.

{
auto p = _listeners.find(ListenerKey{session});
Copy link
Member Author

Choose a reason for hiding this comment

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

ListenerKey was not required for this map, we were using the default shared_ptr operator<

@@ -876,8 +868,7 @@ TopicReaderI::TopicReaderI(
std::move(name),
id)
{
_defaultConfig = {-1, 0, DataStorm::ClearHistoryPolicy::OnAll, DataStorm::DiscardPolicy::None};
Copy link
Member Author

Choose a reason for hiding this comment

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

Move the defaults to the property defaults, and update the code to use getIceProperty.

Comment on lines -973 to -976
else if (p->second == "SendTime")
{
config.discardPolicy = DataStorm::DiscardPolicy::Priority;
}
Copy link
Member Author

Choose a reason for hiding this comment

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

This was bogus, but it seems we don't have any tests that catches this error.

Copy link
Member

@externl externl left a comment

Choose a reason for hiding this comment

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

Looks good to me!

for (auto& t : _topics)
{
runWithTopics(t.first, [&](TopicI* topic, TopicSubscriber&) { topic->detach(t.first, shared_from_this()); });
runWithTopics(t.first, [id = t.first, self](TopicI* topic, TopicSubscriber&) { topic->detach(id, self); });
Copy link
Member

Choose a reason for hiding this comment

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

Could you declare self in the capture block to avoid an extra copy?

Comment on lines +73 to +76
if (value == "Never")
{
return DataStorm::DiscardPolicy::None;
}
Copy link
Member

Choose a reason for hiding this comment

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

I assume Never is the "right" choice here.

Comment on lines +73 to +76
if (value == "Never")
{
return DataStorm::DiscardPolicy::None;
}
Copy link
Member

Choose a reason for hiding this comment

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

Or parse both "Never" and "None" to DiscardPolicy::None?

@pepone pepone merged commit f9b8b96 into zeroc-ice:main Nov 19, 2024
19 checks passed
InsertCreativityHere pushed a commit to InsertCreativityHere/compiler-comparison that referenced this pull request Dec 26, 2024
InsertCreativityHere pushed a commit to InsertCreativityHere/compiler-comparison that referenced this pull request Jan 1, 2025
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.

3 participants