The Agent Cache should return copies of the RPC responses
- Dominant language
- Go
- Stars
- 30.1k
- Forks
- 4.6k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 43
Description
#### Overview of the Issue
When not using the agent cache, RPC responses returned can be considered "owned" by the caller. The data can be modified or filtered as necessary. However when the agent cache is in use the data cannot be modified as its being held onto by the cache itself and other code could be using it. In the best case that would result in incorrect data but in the worst it would result in consul crashing.
#### Suggested Fix
I think it would be okay to have the cache copy the cached RPC responses before returning them. It would be a little overhead but seems worth it in order to provide similar semantics to doing the regular RPC request.
This other PR is one example of a bug that can crop up because of the issue: https://github.com/hashicorp/consul/pull/5398
Contributor guide
Assessment
This issue has not been assessed yet.