smjn commented on code in PR #24110:
URL: https://github.com/apache/kafka/pull/24110#discussion_r4482166518
##########
trogdor/src/main/java/org/apache/kafka/trogdor/workload/ShareConsumeBenchWorker.java:
##########
@@ -140,11 +148,70 @@ private static AlterConfigOp setOp(String name, String
value) {
return new AlterConfigOp(new ConfigEntry(name, value),
AlterConfigOp.OpType.SET);
}
+ /**
+ * Sets the configs unless the resource already has them, retrying on
failure. Every consumer of a share group sets
+ * up the same DLQ, so the later ones find the configs already in place
and leave them alone instead of all
+ * rewriting the same group config at once. The broker has been seen to
reject such concurrent writes with an
+ * UnknownServerException.
+ */
private static void alterConfigs(Admin adminClient, ConfigResource
resource, Collection<AlterConfigOp> ops) throws Exception {
+ alterConfigs(adminClient, resource, ops, Time.SYSTEM);
+ }
+
+ // Package-private so that a test can pass a MockTime and not wait for the
real backoff.
+ static void alterConfigs(Admin adminClient, ConfigResource resource,
Collection<AlterConfigOp> ops, Time time) throws Exception {
+ Exception failure = null;
+ for (int attempt = 1; attempt <= ALTER_CONFIGS_ATTEMPTS; attempt++) {
+ try {
+ // Another consumer can set the configs between this describe
and the alter below. That is harmless:
+ // every consumer sets the same values, so a second write
changes nothing, and if the broker fails it
+ // because it overlaps with the other write, the next
attempt's describe sees the values and stops.
+ // The describe only makes the concurrent writes rarer, it is
not a lock.
+ if (hasConfigs(adminClient, resource, ops)) {
+ log.info("{} already has the configs {}, leaving them
alone (attempt {}/{}).",
+ resource, ops, attempt, ALTER_CONFIGS_ATTEMPTS);
+ return;
+ }
+ adminClient.incrementalAlterConfigs(Map.of(resource,
ops)).all().get(60, TimeUnit.SECONDS);
+ log.info("Altered configs {} of {} (attempt {}/{}).", ops,
resource, attempt, ALTER_CONFIGS_ATTEMPTS);
+ return;
+ } catch (Exception e) {
Review Comment:
Yes, that was the idea as this isn't is production path and while the
cluster is coming up - these could be possible and it gives room to the user to
apply the configs.
However, will add specialization checks to retry conditionally.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]