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

Alternator: support "transactions" feature #5064

Open
nyh opened this issue Sep 19, 2019 · 8 comments
Open

Alternator: support "transactions" feature #5064

nyh opened this issue Sep 19, 2019 · 8 comments
Labels
area/alternator Alternator related Issues enhancement P4 Low Priority
Milestone

Comments

@nyh
Copy link
Contributor

nyh commented Sep 19, 2019

"Transactions" are a new DynamoDB feature (announced in November 2018) which allows atomic (all-or-nothing) updates to one or more tables in the same region. This feature is unrelated to the older single-item conditional updates feature - which in Scylla are called lightweight transactions, and which we already support but without the correct isolation guarantees (see issue #5054).

See https://docs.google.com/document/d/1i4yjF5OSAazAY_-T8CBce9-2ykW4twx_E_Nt2zDoOVs/edit# (section "Transactions") for some implementation ideas.

The new API requests for this feature: TransactWriteItems and TransactGetItems.

@nyh nyh added low area/alternator Alternator related Issues labels Sep 19, 2019
@slivne slivne added this to the 3.x milestone Sep 22, 2019
@nyh
Copy link
Contributor Author

nyh commented Jul 6, 2021

In https://docs.google.com/document/d/1i4yjF5OSAazAY_-T8CBce9-2ykW4twx_E_Nt2zDoOVs/edit#heading=h.qmq6kez54pdq I mentioned that:

Before this feature [transactions] was added, users were encouraged to use Amazon’s transaction client library which implements transactions on top of other DynamoDB features. We can encourage them to do the same. Perhaps eventually we can take ideas from this library on how to implement transactions on the server side.

This may be a good way to have full support for this feature - albeit somewhat ugly and slow - quickly, without huge investments in Scylla infrastructures to support transactions in CQL. Amazon have good design document https://github.com/awslabs/dynamodb-transactions/blob/master/DESIGN.md on how they implemented full-fledged multi-item cross-table transactions over pre-existing DynamoDB features, and I'm optimistic we can do the same while emulating their new transaction API. I'm optimistic that this can be done in 1-2 weeks instead of the original 1-2 month estimate (which itself was optimistic) for a from-scratch implementation of this feature.

@nyh
Copy link
Contributor Author

nyh commented Jul 7, 2021

I summarized the option of providing transactions over existing features in a new design document https://docs.google.com/document/d/1d0RmuWPkGmoKPXwJ2mY6HLhf40otuMvfOKNUYcfn2Cg/edit#. There are good news and bad news. The good news is that this I think this technique can work. The bad news is that the performance will be bad (e.g., a transactional write will be 7-9 times more expensive than a regular LWT write, while the ratio is 2 in DynamoDB), and some edge cases involving races of transactional and non-transactional operations, or interaction of transactions and GSI or streams, will be tricker to solve.

@nyh
Copy link
Contributor Author

nyh commented Jul 13, 2021

Our LWT implementation already supports conditional batches: "The entire conditional batch has an isolated view of the database and is executed using all-or-nothing principle.".

We could use this existing capability to implement the DynamoDB Transactions feature with one important limitation - that all operations in a transaction must be on the same partition. Although this limited feature is not as powerful as the full DynamoDB feature (that can cross partitions and even tables), it will probably be good enough for some users - and we should hopefully be able to provide this subset quickly and most importantly - efficiently (it will have the same performance as the current CAS-based writes).

@nyh
Copy link
Contributor Author

nyh commented May 9, 2022

Amazon's FAST '19 presentation by Doug Terry on how DynamoDB transactions were implemented: https://www.usenix.org/conference/fast19/presentation/terry
A nice summary of their approach and why it is simpler than other possible approaches: https://www.mydistributed.systems/2021/12/dynamodb.html

Some additional interesting links:

@DoronArazii DoronArazii added P4 Low Priority and removed low labels Dec 28, 2022
@jexh
Copy link

jexh commented Jan 27, 2023

Is there a core scylladb issue describing the requirements to support this issue? I can't find anything that requests cross-table transaction support in the issue list - perhaps I just can't think of the correct search phrase?

@nyh
Copy link
Contributor Author

nyh commented Jan 29, 2023

Is there a core scylladb issue describing the requirements to support this issue?

I don't think there is such an issue open. I agree that it would also be nice to have multi-item transactions in CQL and that whatever core feature we'll end up implementing may also be used in CQL to implement a similar transaction feature. The reason why I opened this issue specifically for Alternator (ScyllaDB's DynamoDB-compatible API) is that it is a requirement for full DynamoDB compatibility, and that feature has known behavior (defined by Amazon). For the CQL feature it would be a completely new feature and we'll need to design it and determine how exactly it should behave. Or maybe it should be compatible with the planned Cassandra feature - https://cwiki.apache.org/confluence/display/CASSANDRA/CEP-15%3A+General+Purpose+Transactions (a.k.a. "Accord").

UPDATE: CEP-15: General Purpose Transactions was officially accepted in Cassandra, there is an issue - https://issues.apache.org/jira/browse/CASSANDRA-17092, and will probably miss Cassandra 5.0 and be in Cassandra 5.1. So to maintain Cassandra compatibility, the CQL feature was already defined for us.

@jexh
Copy link

jexh commented Jan 30, 2023 via email

@nyh
Copy link
Contributor Author

nyh commented Jul 3, 2023

Originally, DynamoDB transactions were limited to contain 25 read or write requests. Starting in September 2022, this limit was increased to 100 operations in a single transaction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/alternator Alternator related Issues enhancement P4 Low Priority
Projects
None yet
Development

No branches or pull requests

5 participants