[MDEV-28330] Hashicorp: Document key caching and key version caching Created: 2022-04-17 Updated: 2023-11-27 Resolved: 2022-05-10 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Documentation, Encryption, Plugins |
| Affects Version/s: | N/A |
| Fix Version/s: | 10.9.1 |
| Type: | Bug | Priority: | Major |
| Reporter: | Elena Stepanova | Assignee: | Julius Goryavsky |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | Cloned | ||
| Issue Links: |
|
||||||||||||||||||||||||||||
| Description |
|
According to the description in hashicorp_key_management.cnf, key cache related variables mean the following:
The test below does the following:
Since key cache is enabled and the (default) timeout is 60 seconds, presumably it should still work and the table should be created using the key from the cache. It doesn't happen however, the statement fails due to the missing key.
There are no test cases coming with the plugin to validate any cache functionality, so there is still a room for interpretation. If expectations in the test above are false, then at least add tests to indicate how the cache is expected to act, and document it accordingly. |
| Comments |
| Comment by Julius Goryavsky [ 2022-04-19 ] |
|
elenst Inside the plugin, actually two separate caches are implemented - one stores the latest key values (for each key version), the second stores only the latest version numbers for each of the keys. From the server side, the plugin receives two types of requests - to find out the latest version number for the key and to find out the value of the key. The key value is then used to encrypt the data. If caching is completely disabled, or if the timeout parameters are set to zero, then executing a generic statement using keys makes two requests to the hashicorp server - to get the latest version number of the key and then to read the value of the key. If caching is enabled for key values, then the load on the server is ideally halved, because only reading the actual key version number requires a new call to the hashicorp server, but the key value itself can be read from the cache, assuming that the version number has not changed. If both timeout parameters are not equal to zero, then the load on the server drops dramatically, because it is possible to do without requesting the number of the current version of the key. But the reverse side of the coin is that if the user changes the key from the hashicorp side, for example, using the administrative utility, then we will read outdated data until the timeout expires. This may not be safe for some of our users if they want to always encrypt with the latest version of the key. It is possible as a compromise to make the timeout value for the versions significantly less than the timeout value for the key values themselves, however during debugging with customer they asked to keep the default behavior of the system and therefore the second parameter was set to zero. A separate variable to enable or disable caching (instead of setting timeouts to zero) allows you to disable caching without losing the old timeouts so that caching can be enabled and disabled dynamically without losing the timeouts. |
| Comment by Elena Stepanova [ 2022-04-19 ] |
|
I see, thanks. Then, please just add test cases for both caches and interaction of their timeouts. |
| Comment by Elena Stepanova [ 2022-05-07 ] |
|
I'm keeping it open for documentation purposes. |
| Comment by Julius Goryavsky [ 2022-05-10 ] |
|
Fixed: https://github.com/MariaDB/server/commit/0902cfaec8cf15c042b1c2159db8ffc97e9bce95 |