Patent attributes
Techniques are described herein for efficiently and expeditiously performing key rotation and key replacement. In an embodiment, a key replacement request is received that specifies one or more key names of a plurality of key names. A location-to-key-name mapping that maps the plurality of key names to a plurality of encrypted-data locations is used to determine one or more encrypted-data locations that are mapped to the one or more key names. A first set of messages is generated where each message identifies a table that is associated with the one or more encrypted-data locations. The first set of messages is stored in a queue for processing by a first plurality of worker processes. Each worker process of the first plurality of worker processes retrieves a message of the first set of messages from the queue and generates a message of a second set of messages that identifies a subset of encrypted data records from the table identified in the message of the first set of messages. Each message of the second set of messages is stored in a distinct queue which is assigned to a worker process of a second plurality of worker processes. Each worker process of the second plurality of worker processes retrieves the message from the assigned queue, decrypts the subset of encrypted data records identified in the respective message, re-encrypts the decrypted data records using a new encryption key that corresponds to a new key name, and stores the re-encrypted data records in a database.