-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Alternator: support TTL #5060
Comments
By the way, as noted by @amoskong and @fastio, the Redis API also has a per-item (not per-cell) TTL, which will need a similar feature:
The above documentation says that expiration may be delayed by only 1ms after the specified expiration time. Because we obviously can't find and delete expired data with such accuracy, we will need to check for the possibility of expiration in every read - so that even if expired data is not expunged from disk yet, it's at least not returned. Note that this read-time check is not necessary in Alternator - the DynamoDB documentation https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/howitworks-ttl.html explains that an item may be deleted an unspecified long time ("typically" up to 48 hours) after it was requested to be expired - and until the final deletion the expired items can still be read and modified (and it's even possible to change their expiration time, to cancel their would-be deletion). |
An idea on how to implement the TTL feature quickly but somewhat inefficiently: Now that Alternator uses LWT for every write and writes are substantially slower, one way we can implement the TTL feature over the existing Scylla TTL is by making every write a read-modify-write operation, as detailed below. Note that an LWT write which needs to read is a bit slower than an LWT write that doesn't read, but probably not much slower.
|
We just had an interesting discussion on the mailing list - see https://groups.google.com/g/scylladb-dev/c/Ddv31GGB9pI - on the the compaction-based implementation, some implementation details and possible pitfalls, and how it would work for the Alternator and Redis APIs. |
The implementation needs to take into account more aspects: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/howitworks-ttl.html " Items are removed from any local secondary index and global secondary index in the same way as a DeleteItem operation. A delete operation for each item enters the DynamoDB Stream, but is tagged as a system delete and not a regular delete. For more information about how to use this system delete, see DynamoDB Streams and Time to Live.
This has implications on how we can add support for this feature (e.g. entering future tombstones can't be done). |
Right. Since our views/indexes are coordinator-managed, this is hard to do. |
@avikivity as for secondary indexing, isn't it enough to always include the special TTL attribute in the underlying materialized view as well? It will receive all updates via existing mechanisms, and the garbage collection process could then just treat materialized views just as normal tables, removing the rows once they expire. |
DynamoDB TTL docs also mention that:
, which would mean that when reenabling TTL, we'd have to add a column to existing views (which is not legal via CQL, but sounds possible by just upgrading the view schemas). In any case, we could start with one-shot TTLs that cannot be disabled and reenabled to another column, for simplicity's sake. |
I think it should work. Auto-project the TTL attribute to the index. Requires a read-before-write, but we're heading in that direction anyway (and indexes already do that). |
We could launch an index rebuild job (similar to the existing job, but just copies the TTL attribute). |
On Sun, Dec 6, 2020 at 5:52 PM Avi Kivity ***@***.***> wrote:
@avikivity <https://github.com/avikivity> as for secondary indexing,
isn't it enough to always include the special TTL attribute in the
underlying materialized view as well? It will receive all updates via
existing mechanisms, and the garbage collection process could then just
treat materialized views just as normal tables, removing the rows once they
expire.
I think it should work. Auto-project the TTL attribute to the index.
Requires a read-before-write, but we're heading in that direction anyway
(and indexes already do that).
Projection is needed for correct result computation not for deletion.
Deletion should be done via the base table updates (like any other
operation in MV/SI) - if the base table row is deleted the MV/SI will be
deleted as well.
—
… You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#5060 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA2OCCFR5HA63HTWF3LO2J3STOSE3ANCNFSM4IYEE5JQ>
.
|
On Sun, Dec 6, 2020 at 5:53 PM Avi Kivity ***@***.***> wrote:
DynamoDB TTL docs also mention that:
You cannot reconfigure TTL to look for a different attribute. You must
disable TTL, and then reenable TTL with the new attribute going forward.
, which would mean that when reenabling TTL, we'd have to add a column to
existing views (which is not legal via CQL, but sounds possible by just
upgrading the view schemas). In any case, we could start with one-shot TTLs
that cannot be disabled and reenabled to another column, for simplicity's
sake.
We could launch an index rebuild job (similar to the existing job, but
just copies the TTL attribute).
We should test out how TTL update works in DynamoDB and see how it operates
when switching the TTL column to better understand what approach we should
take. We should check the edge cases what happens in MV/SI if the column is
not used as part of the projection and the TTL expires does the MV/SI work
or not. What happens when the column is changed does the MV/SI work under a
changed column or not.
I am not sure the rebuild approach suggested will work - during rebuild the
index is not avail
We need to be able to have two indexes - current one and new one and switch
between them once rebuild is done.
We do not have that capability today.
An alternate approach is for DynamoDB is to always include in the SI/MV an
additional TTL column (even if the column is projected in the MV/SI). That
column will hold the copy of the column used for TTL - if the column is
changed and is not part of the MV/SI projected columns its not an issue we
have a place to store the value.
If the TTL column is updated to be empty / another column a full scan will
be done updating the TTL column data in the View/SI (this will be a
background process - similar to rebuild).
As the rebuild/update will be long - we can use something like a truncation
record for point in time recording from which point TTL info should be
considered correct - to help detect records that have TTL value that was
not updated and should be considered as non existing.
The benefit of this approach is that the MV/SI exists all the time - there
is no need to hold duplicate indexing /switch indexing
Again, checking what DynamoDB dopes under the edge cases (MV/SI doesn't
contain TTL column, MV/SI doesn't contain TTL column - when its first set)
- will help understand what they used in their implementation and direct us
to a compatible solution aligned with how they support TTL column changes.
… —
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#5060 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA2OCCCODRPJZRGFPZSSFELSTOSIBANCNFSM4IYEE5JQ>
.
|
This patch adds a test suite for the DynamoDB API's TTL (item expiration) feature. The tests check the two new API commands added by this feature (UpdateTimeToLive and DescribeTimeToLive), and also how items are expired in practice. Because DynamoDB has long delays in expiring items and in configuring expiration, so of these tests are marked "verylong" because they take up to 30 minutes to complete, and are skipped in ordinary test runs (use "--runverylong" to run them). Two things are *not* yet tested by these tests: 1. How in a table with a GSI/LSI, expiring an item also expires the index item. 2. How in a table with Streams enabled, an expired item also generates a special stream event. All these tests currently pass on DynamoDB, but xfail on Alternator because the two commands UpdateTimeToLive and DescribeTimeToLive are currently rejected by Alternator. Refs scylladb#5060 Signed-off-by: Nadav Har'El <nyh@scylladb.com>
Started to work on this feature. A draft pull request - currently including just tests - is in #8564. |
This patch adds a test suite for the DynamoDB API's TTL (item expiration) feature. The tests check the two new API commands added by this feature (UpdateTimeToLive and DescribeTimeToLive), and also how items are expired in practice. Because DynamoDB has long delays in expiring items and in configuring expiration and some of these tests take up to 30 minutes to complete, we mark them "verylong", and are skipped in ordinary test runs - use the "--runverylong" option to run them. Two things are *not* yet tested by these tests: 1. How in a table with a GSI/LSI, expiring an item also expires the index item. 2. How in a table with Streams enabled, an expired item also generates a special stream event. All these tests currently pass on DynamoDB, but xfail on Alternator because the two commands UpdateTimeToLive and DescribeTimeToLive are currently rejected by Alternator. Refs scylladb#5060 Signed-off-by: Nadav Har'El <nyh@scylladb.com>
This patch adds a comprehensive test suite for the DynamoDB API's TTL (item expiration) feature. The tests check the two new API commands added by this feature (UpdateTimeToLive and DescribeTimeToLive), and also how items are expired in practice, and how item expiration interacts with other features such as GSI, LSI and DynamoDB Streams. Because DynamoDB has extremely long delays until items are expired, or until expiration configuration may be changed, several of these tests take up to 30 minutes to complete. We mark these tests with the "verylong" marker, so they are skipped in ordinary test runs - use the "--runverylong" option to run them. All these tests currently pass on DynamoDB, but xfail on Alternator because the two commands UpdateTimeToLive and DescribeTimeToLive are currently rejected by Alternator. Refs scylladb#5060 Signed-off-by: Nadav Har'El <nyh@scylladb.com>
This patch adds a comprehensive test suite for the DynamoDB API's TTL (item expiration) feature. The tests check the two new API commands added by this feature (UpdateTimeToLive and DescribeTimeToLive), and also how items are expired in practice, and how item expiration interacts with other features such as GSI, LSI and DynamoDB Streams. Because DynamoDB has extremely long delays until items are expired, or until expiration configuration may be changed, several of these tests take up to 30 minutes to complete. We mark these tests with the "verylong" marker, so they are skipped in ordinary test runs - use the "--runverylong" option to run them. All these tests currently pass on DynamoDB, but xfail on Alternator because the two commands UpdateTimeToLive and DescribeTimeToLive are currently rejected by Alternator. Refs scylladb#5060 Signed-off-by: Nadav Har'El <nyh@scylladb.com>
This patch adds a comprehensive test suite for the DynamoDB API's TTL (item expiration) feature. The tests check the two new API commands added by this feature (UpdateTimeToLive and DescribeTimeToLive), and also how items are expired in practice, and how item expiration interacts with other features such as GSI, LSI and DynamoDB Streams. Because DynamoDB has extremely long delays until items are expired, or until expiration configuration may be changed, several of these tests take up to 30 minutes to complete. We mark these tests with the "verylong" marker, so they are skipped in ordinary test runs - use the "--runverylong" option to run them. All these tests currently pass on DynamoDB, but xfail on Alternator because the two commands UpdateTimeToLive and DescribeTimeToLive are currently rejected by Alternator. Refs scylladb#5060 Signed-off-by: Nadav Har'El <nyh@scylladb.com>
This series includes a comprehensive test suite for the DynamoDB API's TTL (item expiration) feature described in issue #5060. Because we have not yet implemented the TTL feature in Alternator, all of the tests still xfail, but they all pass on DynamoDB and demonstrate exactly how the TTL feature works and how it interacts with other features such as LSI, GSI and Streams. The patch which introduces these tests is heavily commented to explain exactly what it tests, and why. Because DynamoDB only expires items some 10-30 minutes after their expiration time (the documentation even suggests it can be delayed by 24 hours!), some of these tests are extremely long (up to 30 minutes!), so we also introduce in this series a new marker for "verylong" tests. verylong tests are skipped by default, unless the "--runverylong" option is given. In the future, when we implement the TTL feature in Alternator and start testing it, we may be able to configure it with a much shorter expiration timeout and then we might be able to run these tests in a reasonable time and make them run by default. Closes #8564 * github.com:scylladb/scylla: test/alternator: add tests for the Alternator TTL feature test/alternator: add marker for "veryslow" tests test/alternator: add new_test_table() utility function
This series includes a comprehensive test suite for the DynamoDB API's TTL (item expiration) feature described in issue #5060. Because we have not yet implemented the TTL feature in Alternator, all of the tests still xfail, but they all pass on DynamoDB and demonstrate exactly how the TTL feature works and how it interacts with other features such as LSI, GSI and Streams. The patch which introduces these tests is heavily commented to explain exactly what it tests, and why. Because DynamoDB only expires items some 10-30 minutes after their expiration time (the documentation even suggests it can be delayed by 24 hours!), some of these tests are extremely long (up to 30 minutes!), so we also introduce in this series a new marker for "verylong" tests. verylong tests are skipped by default, unless the "--runverylong" option is given. In the future, when we implement the TTL feature in Alternator and start testing it, we may be able to configure it with a much shorter expiration timeout and then we might be able to run these tests in a reasonable time and make them run by default. Closes #8564 * github.com:scylladb/scylla: test/alternator: add tests for the Alternator TTL feature test/alternator: add marker for "veryslow" tests test/alternator: add new_test_table() utility function
... from Nadav Har'El This small series adds a stub implementation of Alternator's UpdateTimeToLive and DescribeTimeToLive operations. These operations can enable, disable, or inquire about, the chosen expiration-time attribute. Currently, the information about the chosen attribute is only saved, with no actual expiration of any items taking place. Because this is an incomplete implementation of this feature, it is not enabled unless an experimental flag is enabled on all nodes in the cluster. See the individual patches for more information on what this series does. Refs #5060. Closes #9345 * github.com:scylladb/scylla: test/alternator: rename utility function test_table_name() alternator: stub TTL operations alternator: make three utility functions in executor.cc non-static test/alternator: test another corner case of TTL
…ce' from Nadav Har'El In this patch series we add an implementation of an expiration service to Alternator, which periodically scans the data in the table, looking for expired items and deleting them. We also continue to improve the TTL test suite to cover additional corner cases discovered during the development of the code. This implementation is good enough to make all existing tests but one, plus a few new ones, pass, but is still a very partial and inefficient implementation littered with FIXMEs throughout the code. Among other things, this initial implementation doesn't do anything reasonable about pacing of the scan or about multiple tables, it scans entire items instead of only the needed parts, and because each shard "owns" a different subset of the token ranges, if a node goes down, partitions which it "owns" will not get expired. The current tests cannot expose these problems, so we will need to develop additional tests for them. Because this implementation is very partial, the Alternator TTL continues to remain "experimental", cannot be used without explicitly enabling this experimental feature, and must not be used for any important deployment. Refs #5060 but doesn't close the issue (let's not close it until we have a reasonably complete implementation - not this partial one). Closes #9624 * github.com:scylladb/scylla: alternator: fix TTL expiration scanner's handling of floating point test/alternator: add TTL test for more data test/alternator: remove "xfail" tag from passing tests in test_ttl.py test/alternator: make test_ttl.py tests fast on Alternator alternator: initial implmentation of TTL expiration service alternator: add another unwrap_number() variant alternator: add find_tag() function test/alternator: test another corner case of TTL setting test/alternator: test TTL expiration for table with sort key test/alternator: improve basic test for TTL expiration test/alternator: extract is_aws() function
…ce' from Nadav Har'El In this patch series we add an implementation of an expiration service to Alternator, which periodically scans the data in the table, looking for expired items and deleting them. We also continue to improve the TTL test suite to cover additional corner cases discovered during the development of the code. This implementation is good enough to make all existing tests but one, plus a few new ones, pass, but is still a very partial and inefficient implementation littered with FIXMEs throughout the code. Among other things, this initial implementation doesn't do anything reasonable about pacing of the scan or about multiple tables, it scans entire items instead of only the needed parts, and because each shard "owns" a different subset of the token ranges, if a node goes down, partitions which it "owns" will not get expired. The current tests cannot expose these problems, so we will need to develop additional tests for them. Because this implementation is very partial, the Alternator TTL continues to remain "experimental", cannot be used without explicitly enabling this experimental feature, and must not be used for any important deployment. Refs #5060 but doesn't close the issue (let's not close it until we have a reasonably complete implementation - not this partial one). Closes #9624 * github.com:scylladb/scylla: alternator: fix TTL expiration scanner's handling of floating point test/alternator: add TTL test for more data test/alternator: remove "xfail" tag from passing tests in test_ttl.py test/alternator: make test_ttl.py tests fast on Alternator alternator: initial implmentation of TTL expiration service alternator: add another unwrap_number() variant alternator: add find_tag() function test/alternator: test another corner case of TTL setting test/alternator: test TTL expiration for table with sort key test/alternator: improve basic test for TTL expiration test/alternator: extract is_aws() function
…ce' from Nadav Har'El In this patch series we add an implementation of an expiration service to Alternator, which periodically scans the data in the table, looking for expired items and deleting them. We also continue to improve the TTL test suite to cover additional corner cases discovered during the development of the code. This implementation is good enough to make all existing tests but one, plus a few new ones, pass, but is still a very partial and inefficient implementation littered with FIXMEs throughout the code. Among other things, this initial implementation doesn't do anything reasonable about pacing of the scan or about multiple tables, it scans entire items instead of only the needed parts, and because each shard "owns" a different subset of the token ranges, if a node goes down, partitions which it "owns" will not get expired. The current tests cannot expose these problems, so we will need to develop additional tests for them. Because this implementation is very partial, the Alternator TTL continues to remain "experimental", cannot be used without explicitly enabling this experimental feature, and must not be used for any important deployment. Refs #5060 but doesn't close the issue (let's not close it until we have a reasonably complete implementation - not this partial one). Closes #9624 * github.com:scylladb/scylla: alternator: fix TTL expiration scanner's handling of floating point test/alternator: add TTL test for more data test/alternator: remove "xfail" tag from passing tests in test_ttl.py test/alternator: make test_ttl.py tests fast on Alternator alternator: initial implmentation of TTL expiration service alternator: add another unwrap_number() variant alternator: add find_tag() function test/alternator: test another corner case of TTL setting test/alternator: test TTL expiration for table with sort key test/alternator: improve basic test for TTL expiration test/alternator: extract is_aws() function
At this point, we already have support for TTL in Alternator, although it is still marked "experimental". |
…hlik Currently, TTL is listed as one of the experimental features: https://docs.scylladb.com/stable/alternator/compatibility.html#experimental-api-features This PR moves the feature description from the Experimental Features section to a separate section. I've also added some links and improved the formatting. @tzach I've relied on your release notes for RC1. Refs: #5060 Closes #11997 * github.com:scylladb/scylladb: Update docs/alternator/compatibility.md doc: update the link to Enabling Experimental Features doc: remove the note referring to the previous ScyllaDB versions and add the relevant limitation to the paragraph doc: update the links to the Enabling Experimental Features section doc: add the link to the Enabling Experimental Features section doc: move the TTL Alternator feature from the Experimental Features section to the production-ready section
This issue is about supporting DynamoDB's TTL feature, which is very different from the Scylla feature of the same name:
While Scylla's TTL allows individual column values to be expired, DynamoDB's TTL is different - it specifies expiration times for entire items.
DynamoDB’s TTL works by specifying with
UpdateTimeToLive
, for each table you want TTL for, the name of an attribute which will hold an item’s expiration time - in seconds since the Unix epoch. An item with this attribute set to a time older than the current time will eventually be deleted. TheDescribeTimeToLive
operation can be used to inquire about a table’s TTL setting.The TTL documentation explains that “a background job checks the TTL attribute of items to see if they are expired.”. We could do this too, and maybe have to do it - although it is inefficient.
Considering Scylla already has compaction and processes in place to expire data, it would be nice if we could reuse those. We can perhaps do something like this: add to the table a TTL column (in addition to the map we always have). When an
UpdateItem
orPutItem
operation changes an item’s chosen TTL attribute (we know its name), also put this value into the TTL column with the same time also as timestamp. During compaction, if the Unix time specified in the TTL column has passed, we add a row tombstone (i.e., a range tombstone) with the column’s timestamp. However, there’s a big difficulty to correctly support the changing of an item's TTL. The problem is that a non-major compaction may not see all the data, so see an old TTL value and decide to delete data based on this old TTL value. We may need to do this TTLing only if we're sure the compaction includes all the sstables with item (as we do today in tombstone GC). Also since this node may have missed a TTL update, we need to be sure a repair happened, so we need to wait for GC grace period (exactly as we do in tombstone GC). Another option is to have a new additional primary-key bloom filter. I’m worried that this last option is an overkill for just the TTL feature, and will also be inefficient (and have high false positives) when there are many small sstables (e.g., LCS).The text was updated successfully, but these errors were encountered: