Skip to content

Conversation

@akrambek
Copy link
Contributor

Fixes #1495

@akrambek akrambek marked this pull request as ready for review June 24, 2025 12:34
Comment on lines +160 to +167
for (BindingConfig binding : namespace.bindings)
{
BindingController controller = controllersByType.get(binding.type);
if (controller != null)
{
controller.detach(binding);
}
}
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 need to offer this as a NamespaceTask too, to make sure it executes on the boss thread, not the caller thread.

private void register(
NamespaceConfig namespace)
{
this.boss.attach(namespace).join();
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
this.boss.attach(namespace).join();
boss.attach(namespace).join();

{
if (namespace != null)
{
boss.detach(namespace);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
boss.detach(namespace);
boss.detach(namespace).join();

{
try
{
controllersByType.values().forEach(BindingController::detachAll);
Copy link
Contributor

Choose a reason for hiding this comment

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

This detachAll() for EngineBoss and BindingController seems inconsistent with the design of separation between EngineWorker and BindingHandler.

Instead, we can keep track of the NamespaceConfigs that we have attached to the EngineBoss and then iterate each NamespaceConfig to here in doClose and detach them all.

if (route != null)
{
final TcpServer server = new TcpServer(binding.id, route.id, network);
final TcpServer server = new TcpServer(bindingId, route.id, network);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
final TcpServer server = new TcpServer(bindingId, route.id, network);
final TcpServer server = new TcpServer(binding.id, route.id, network);

We already used bindingId to resolve binding so at this point it is more correct to use binding.id.

if (binding != null)
{
route = router.resolve(binding, traceId, authorization, beginEx);
route = binding.resolve(binding, traceId, authorization, beginEx);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
route = binding.resolve(binding, traceId, authorization, beginEx);
route = binding.resolve(traceId, authorization, beginEx);

Comment on lines 105 to 111
public InetSocketAddress resolve(
TcpBindingConfig binding,
long traceId,
long authorization,
ProxyBeginExFW beginEx)
{
final TcpOptionsConfig options = binding.options;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
public InetSocketAddress resolve(
TcpBindingConfig binding,
long traceId,
long authorization,
ProxyBeginExFW beginEx)
{
final TcpOptionsConfig options = binding.options;
public InetSocketAddress resolve(
long traceId,
long authorization,
ProxyBeginExFW beginEx)
{

private final LongConsumer recordUsage;

private int usage;
private volatile int usage;
Copy link
Contributor

Choose a reason for hiding this comment

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

Did we change this to volatile to handle access from engine boss thread during tcp accept?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No sorry I was debugging and forgot to remove it

Comment on lines 115 to 120
@Override
public void detachAll()
{
serversById.values().forEach(CloseHelper::quietCloseAll);
serversById.clear();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove this method.

}

public void detach(
private void detachNamespace(
Copy link
Contributor

Choose a reason for hiding this comment

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

Please move this private method down below attachNamespace.

private void attachNamespace(
NamespaceConfig namespace)
{
namespaces.add(namespace);
Copy link
Contributor

Choose a reason for hiding this comment

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

This is good.

We also need symmetrical namespaces.remove(namespace); in detachNamespace method.

Note that namespaces can be added and removed while engine is still running, so detachNamespace is not only for doClose case, that's why we need to make sure it is kept accurate.

Comment on lines +140 to +145
public void attachNow(
NamespaceConfig namespace)
{
attach(namespace).join();
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we still need attachNow and detachNow? If not, let's remove them.


public class EngineBoss implements EngineController, Agent
{
private static final String AGENT_NAME = "EngineBoss";
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
private static final String AGENT_NAME = "EngineBoss";
private static final String AGENT_NAME = "engine/boss";

Copy link
Contributor

Choose a reason for hiding this comment

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

Change agentName to this.agentName = String.format("engine/worker#%d", index);

@jfallows jfallows changed the title Load balancer support Support load balancer health check even at full capacity Jun 28, 2025
@jfallows jfallows merged commit cdee164 into aklivity:develop Jun 28, 2025
39 of 41 checks passed
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.

Zilla can appear unhealthy to tcp health check mechanisms at full engine worker utilization

2 participants