Skip to content

Conversation

@sivagirish81
Copy link
Contributor

@sivagirish81 sivagirish81 commented Aug 5, 2025

READ BEFORE MERGING: All PRs require approval by both Server AND SDK teams before merging! This is why the number of required approvals is "2" and not "1"--two reviewers from the same team is NOT sufficient. If your PR is not approved by someone in BOTH teams, it may be summarily reverted.

What changed?

  • Added two update fairness weight maps to the UpdateTaskQueueConfig api request.
  • Added a fairness_weights map in the taskQueueConfig message to enable persistence and return response.

Why?

  • Allow override of fairness weights for individual fairness keys via UpdateTaskQueueConfig api.

Breaking changes

  • No.

Server PR

@sivagirish81 sivagirish81 marked this pull request as ready for review August 5, 2025 16:39
@sivagirish81 sivagirish81 requested review from a team as code owners August 5, 2025 16:39
Copy link
Contributor

@dnr dnr left a comment

Choose a reason for hiding this comment

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

I think this is simple and sufficient, I'd just tweak the names slightly.

Does anyone have objections to the "-1 to unset"?

Copy link
Member

@cretz cretz left a comment

Choose a reason for hiding this comment

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

(from a structure POV all LGTM, but am deferring SDK review to someone on SDK team more familiar w/ the priority/fairness project, maybe @Sushisource?)

Copy link
Member

@Sushisource Sushisource left a comment

Choose a reason for hiding this comment

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

Makes sense to me.

// If the `rate_limit` field in the `RateLimitUpdate` is missing, remove the existing rate limit.
RateLimitUpdate update_fairness_key_rate_limit_default = 6;
// If set, overrides the fairness weights for the fairness keys.
// Sentinel value -1 is used to unset a fairness weight override.
Copy link
Member

Choose a reason for hiding this comment

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

This is a bit rough. How do we expect unsetting an override to look in CLI, will we ask users to use -1? Arguably a separate list of keys to remove could be clearer, but I do not have strong opinion

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

@stephanos stephanos Sep 26, 2025

Choose a reason for hiding this comment

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

Options I'm considering here now:

(1)

map<string, float> set_fairness_weight_overrides = 7;  // float must be zero or greater
repeated string unset_fairness_weight_overrides = 8;

(2)

message FairnessWeightUpdate {
  string key = 1;
  oneof op {
    float set = 2;
    bool unset = 3;      
  }
}

repeated FairnessWeightUpdate update_fairness_weight_overrides = 7;

(3) AI also suggested this to me. I didn't know proto3 actually had optional. Looks legit.

message FairnessWeightUpdate {
    optional float weight = 1;
}

map<string, FairnessWeightUpdate> update_fairness_weight_overrides = 7;

(1) seems clearest and easiest.

Copy link
Member

Choose a reason for hiding this comment

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

Agreed, 1 is clearest IMO. Would like to avoid optional and empty messages if we can. It is less clear to users to differentiate scalars between 0 and "none" (if optional even makes sense that way). People expect 0 and unset to be the same thing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Approach 1 looks good to me. A couple of points to consider for the server implementation:

  • What should the expected behavior be if a user tries to set a fairness key as well as unset a fairness key in the same request. Do we do a sanity check and drop the request as a whole or do we prioritize the update.
  • We should enforce a limit on the number of keys that can be deleted in a single request, similar to how we enforce a limit on the number of fairness weight overrides allowed at a time.
  • Do we also want to support a mechanism for unsetting all overrides at once? This could be useful for reset scenarios.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good points to consider! I'd say

  • "reject if a request contains conflicting requests"
  • +1 to combined update limit
  • could add a bool field (now validation becomes trickier) or declare out of scope for now

Comment on lines 2530 to 2531
// If unset, the fairness weights fall back to the values set during task creation (if any),
// or to the default weight of 1.0.
Copy link
Member

@cretz cretz Sep 25, 2025

Choose a reason for hiding this comment

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

If other values in this request are unset, things remain as is. Are we inconsistently saying for this one field if you don't set it, we are going to revert to fall back values instead of leaving the overrides alone? Or do you mean "If unset" as in if a certain key override is not present at runtime, not whether this field is unset? It is a bit confusing looking at other fields in this request talk about "If not set" which does refer to the field, not the runtime behavior of the value.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If other values in this request are unset, things remain as is. Are we inconsistently saying for this one field if you don't set it, we are going to revert to fall back values instead of leaving the overrides alone?

No. The same behavior applies for this field as well. If the values are not set in the api calls we will leave the overrides untouched.

Suggested change
// If unset, the fairness weights fall back to the values set during task creation (if any),
// or to the default weight of 1.0.
// If unset via sentinel value, the fairness weights fall back to the values set during task creation (if any),
// or to the default weight of 1.0.

If the value of a particular fairness key is unset in the map by using the sentinel value then the statement applies. I can see how it might be confusing.

@cretz
Copy link
Member

cretz commented Sep 25, 2025

(sorry, just noticed a couple of confusing things I commented on, does not have to be blocking since this was already reviewed)

@stephanos stephanos requested review from ShahabT and cretz September 27, 2025 01:34
stephanos and others added 3 commits September 30, 2025 11:50
Co-authored-by: Siva Girish Ramesh <35769591+sivagirish81@users.noreply.github.com>
Copy link
Contributor

@dnr dnr left a comment

Choose a reason for hiding this comment

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

Tbh I think the -1 thing is fine (for an api, not user-facing), but fine either way

@stephanos stephanos merged commit d8216ae into temporalio:master Oct 15, 2025
4 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.

6 participants