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

agent/txn_endpoint: configure max txn request length #7388

Merged
merged 8 commits into from
Mar 5, 2020

Conversation

findkim
Copy link
Contributor

@findkim findkim commented Mar 4, 2020

This PR introduces the option to configure the maximum request length for transaction requests to the /txn endpoint that is distinct from the KV value limit. These changes do not affect the current default behavior of the /txn endpoint and aims to improve clarity on the limits imposed on the transaction by narrowing the usage of the KV value limit to only KV operations.

  • limits.txn_max_req_len
  • Defaults to the suggested raft size, currently ~500KB
  • Adds more context on the difference between the two limits within a transaction
  • Adds documentation on the option
  • Removes the cumulative kv value limit check with preference for the the max txn size restriction.

Copy link
Member

@hanshasselberg hanshasselberg left a comment

Choose a reason for hiding this comment

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

Great PR! Valuable comments, more test, docs and code pretty much done. Left a couple of minor comments.

// maxTxnSize is the size limit (bytes) for for transaction request bodies.
// The default is set to the suggested raft size to keep the total transaction
// size reasonable to account for timely heartbeat signals.
maxTxnSize := int64(s.agent.config.TxnMaxDataSize)
Copy link
Member

Choose a reason for hiding this comment

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

If someone configured KVMaxValueSize, it would be useless after an upgrade. Could you change the code to handle the case where KVMaxValueSize is set too, maybe by falling back to it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

great catch, i'll add a check to fall back if KV limit is greater than the txn limit

// transactions are automatically set to attempt a chunking apply.
// Performance may degrade and warning messages may appear.
if maxTxnSize == 0 {
maxTxnSize = raft.SuggestedMaxDataSize
Copy link
Member

Choose a reason for hiding this comment

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

nit: The default of KVMaxValueSize is set in agent/config/default.go. I would find it easier if this default would be in the same spot, to make it easier to see that they are the same (I just looked it up). Or adding a comment would also help.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that's fair! i see now that all the defaults are in the same location -- moved 👍


// Check Content-Length first before decoding to return early
Copy link
Member

Choose a reason for hiding this comment

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

I know this code existed before, but I don't like the duplication and I am wondering what your opinion is on removing the early return in favor of readability and maintainability.

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 availability of the agents are important, I think it's worth while to reduce the overhead of unnecessary processing time to decode a large request. Though, on the point of readability, what do you think about the change I just pushed up? It simplifies checking of content length from relying on the Content-Length header to using the actual request length.

Copy link
Member

Choose a reason for hiding this comment

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

I like that!

@@ -6217,6 +6217,7 @@ func TestSanitize(t *testing.T) {
"StatsiteAddr": ""
},
"TranslateWANAddrs": false,
"TxnMaxDataSize": 0,
Copy link
Member

Choose a reason for hiding this comment

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

There should be two more places in this file where you are setting a random value in json and hcl configs and check the result afterwards.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Appreciate it! Everything should be added now after following the config field guide

@findkim findkim marked this pull request as ready for review March 5, 2020 20:37
Copy link
Member

@hanshasselberg hanshasselberg left a comment

Choose a reason for hiding this comment

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

Looks great!

@findkim findkim linked an issue Mar 5, 2020 that may be closed by this pull request
@findkim findkim changed the title agent/txn_endpoint: configure max txn size agent/txn_endpoint: configure max txn request length Mar 5, 2020
@findkim findkim merged commit a8f4123 into hashicorp:master Mar 5, 2020
@findkim findkim deleted the max-txn-size branch March 5, 2020 21:42
findkim added a commit that referenced this pull request Mar 12, 2020
configure max transaction size separately from kv limit
findkim added a commit that referenced this pull request Mar 17, 2020
configure max transaction size separately from kv limit
alvin-huang pushed a commit to alvin-huang/consul that referenced this pull request May 6, 2020
configure max transaction size separately from kv limit
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.

KVMaxValueSize should not be enforced on entire txn endpoint data
2 participants