Files
Michael SnowdenandMind.R 4e1ebfdfea Add a Cassandra Queue V2 Implementation (#4819)
<!-- Describe what has changed in this PR -->
**What changed?**
I defined the persistence.QueueV2 interface, which supersedes the
persistence.Queue interface. I also added an implementation of this
interface for Cassandra.

The implementations for delete and merge are left out for now and will
be implemented later. As a result, there is no logic to read/write from
the queues table (to read/write ack levels). Later, the ReadMessages
method will need to be updated to use this as the minimum message id.

<!-- Tell your future self why have you made these changes -->
**Why?**
We plan on using this for the upcoming history task DLQ project.

<!-- How have you verified this change? Tested locally? Added a unit
test? Checked in staging env? -->
**How did you test it?**
The new code has 100% test coverage, even including a test for CAS
application failures due to concurrent writers. I tested that particular
one locally 100 times to verify that it wasn't flaky.

<!-- Assuming the worst case, what can be broken when deploying this
change to production? -->
**Potential risks**
The biggest risk IMO is that because we're doing this piecemeal, we may
realize there's an issue in the database schema and then have to change
it later, which will be a pain if we need to ensure it's backwards
compatible, but we can prevent this by ensuring that those changes are
not split across multiple releases.

<!-- Is this PR a hotfix candidate or require that a notification be
sent to the broader community? (Yes/No) -->
**Is hotfix candidate?**
No.
2023-09-28 10:07:07 -07:00
..

What

This directory contains the cassandra schema for every keyspace that temporal owns. The directory structure is as follows

./schema
   - keyspace1/
   - keyspace2/
        - keyspace.cql     -- Contains the keyspace definition
        - schema.cql       -- Contains the latest & greatest snapshot of the schema for the keyspace
        - versioned
             - v0.1/
             - v0.2/       -- One directory per schema version change
             - v1.0/
                - manifest.json   -- json file describing the change
                - changes.cql     -- changes in this version, only [CREATE, ALTER] commands are allowed

How

Q: How do I update existing schema ?

  • Add your changes to schema.cql
  • Create a new schema version directory under ./schema/keyspace/versioned/vx.x
    • Add a manifest.json
    • Add your changes in a cql file
  • Once you are done with these use the ./temporal-cassandra-tool to update the schema

Q: What's the format of manifest.json

Example below:

  • MinCompatibleVersion is the minimum schema version that your code can handle
  • SchemaUpdateCqlFiles are list of .cql files containing your create/alter commands
{
    "CurrVersion": "0.1",
    "MinCompatibleVersion": "0.1",
    "Description": "base version of schema",
    "SchemaUpdateCqlFiles": [
        "base.cql"
    ]
}