Skip to content

[fix][broker] Copy command fields and fix potential thread-safety in ServerCnx#19517

Merged
nicoloboschi merged 2 commits intoapache:masterfrom
nicoloboschi:copy-command-fields-txn
Feb 23, 2023
Merged

[fix][broker] Copy command fields and fix potential thread-safety in ServerCnx#19517
nicoloboschi merged 2 commits intoapache:masterfrom
nicoloboschi:copy-command-fields-txn

Conversation

@nicoloboschi
Copy link
Copy Markdown
Contributor

Motivation

In #19467 we introduced a couple of possible issues about thread-safety of the BaseCommand and ServerCnx instances.

Original comments from @michaeljmarshall :

Modifications

  • Get the auth fields in the same thread of the connection
  • Copy partitionList instead of reading it in another thread

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

@github-actions github-actions Bot added the doc-not-needed Your PR changes do not impact docs label Feb 14, 2023
return CompletableFuture.completedFuture(false);
}
});
}, ctx.executor());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why modify here?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I requested this change last week because getAuthenticationData() was getting a non-volatile variable. However, before this PR was opened, I contributed #19507. @nicoloboschi - we can probably remove this part of the diff since reading the authenticationData is now thread safe.

In the long term, it might be worth exploring if we should only read this metadata from the event loop, but for now, these variables are volatile.

Copy link
Copy Markdown
Member

@michaeljmarshall michaeljmarshall left a comment

Choose a reason for hiding this comment

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

Thanks for following up on this @nicoloboschi!

return CompletableFuture.completedFuture(false);
}
});
}, ctx.executor());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I requested this change last week because getAuthenticationData() was getting a non-volatile variable. However, before this PR was opened, I contributed #19507. @nicoloboschi - we can probably remove this part of the diff since reading the authenticationData is now thread safe.

In the long term, it might be worth exploring if we should only read this metadata from the event loop, but for now, these variables are volatile.

@nicoloboschi nicoloboschi merged commit 0bb0f6b into apache:master Feb 23, 2023
@nicoloboschi nicoloboschi deleted the copy-command-fields-txn branch February 23, 2023 12:54
nicoloboschi added a commit that referenced this pull request Feb 23, 2023
nicoloboschi added a commit that referenced this pull request Feb 23, 2023
nicoloboschi added a commit to datastax/pulsar that referenced this pull request Feb 28, 2023
…ServerCnx (apache#19517)

(cherry picked from commit 0bb0f6b)
(cherry picked from commit 36582d8)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants