Skip to content

Update Cassandra to write history tasks to new columns #6685

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

Merged
merged 2 commits into from
Mar 11, 2025

Conversation

Shaddoll
Copy link
Member

@Shaddoll Shaddoll commented Feb 24, 2025

What changed?

  • Refactored persistence layer to separate the task serialization logic into a new component
  • Updated Cassandra plugin to encode history tasks into thrift blobs and write them into new columns introduced in Refactor peristence layer to support inserting history tasks of new categories #6671, this is controlled by a dynamic config property
  • Removed some deprecated data types and unused data field from persistence task types

Why?
This is a followup change of #6671. We want to migrate Cassandra's transfer, timer, replication task data from typed columns to encoded blob columns introduced in that PR. After this change Cassandra will be in "dual write" mode.
Another followup PR will be created to allow specifying which column we read data from. Currently, we still read history tasks from the original columns as before.
No backfill is required for transfer tasks and replication tasks because old data not inserted with "dual write" mode will be gone soon after the deployment of this PR. A backfill process is required for timer tasks.

How did you test it?
Unit test, manual tests in dev2 environment, persistence test will be created in the followup PR that enables migration on reading tasks

Potential risks
tasks not encoded correctly (no impact production until we enable migration on reading tasks), history task processing might be broken

Release notes

Documentation Changes

@Shaddoll Shaddoll force-pushed the persistence branch 4 times, most recently from a0ced83 to 4ff2b56 Compare February 24, 2025 07:17
@Shaddoll Shaddoll changed the title wip: Update Cassandra to write history tasks to new columns Update Cassandra to write history tasks to new columns Feb 24, 2025
@Shaddoll Shaddoll force-pushed the persistence branch 2 times, most recently from ced5620 to 8f00caf Compare March 10, 2025 19:44
tasks = append(tasks, t)
var blob *persistence.DataBlob
if d.dc.EnableShardIDMetrics() {
data, err := d.taskSerializer.SerializeTask(persistence.HistoryTaskCategoryTransfer, task)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a follow up, we can consider cherry picking which fields are being serialized here to avoid redundancy. e.g. domainid/wfid/runid are available in the same row so they can be omitted.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they cannot be omitted, because they are not stored in the primary key

DomainID: executionInfo.DomainID,
TaskList: decision.TaskList,
ScheduleID: decision.ScheduleID,
TargetDomainID: executionInfo.DomainID,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this rename impact deserialization of already saved tasks on sql stores?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And we probably don't need this as a separate field anymore since you have introduced WorkflowIdentifier. Could this be removed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it doesn't impact deserialization. It's the in-memory representation of history tasks.

I think it could be probably be removed and we can use domainID because activity and decisions cannot be scheduled in another domain. But I'll avoid that change in this PR and review it later.

@@ -2037,6 +2037,8 @@ const (
// Allowed filters: DomainName,TasklistName,TasklistType
MatchingEnableClientAutoConfig

EnableNoSQLHistoryTaskDualWriteMode
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: it's not super clear from the name of this that this is referring to a migration of row encoding. I'd suggest either adding some detail to the name about that or at least a comment indicating it's intent. Otherwise it seems a lot more general than what appears to be a one-time migration.


testCases := []struct {
category persistence.HistoryTaskCategory
task persistence.Task
Copy link
Member

@davidporter-id-au davidporter-id-au Mar 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest generating task data so that new fields added will be caught by the test if there's a mapping problem in your round-trip tests. see common/testing/testdatagen if it's useful.

@Shaddoll Shaddoll merged commit 2795c37 into cadence-workflow:master Mar 11, 2025
22 checks passed
@Shaddoll Shaddoll deleted the persistence branch March 11, 2025 02:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants