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

Update C* queries about execution table with timestamps #6593

Merged

Conversation

bowenxia
Copy link
Member

@bowenxia bowenxia commented Jan 7, 2025

What changed?
Update queries about execution table with created_time and last_updated_time
Updated unit test accordingly

Why?
to make rows in Cassandra easier to debug

How did you test it?
unit test
manually tested in mono repo

Potential risks

Release notes

Documentation Changes

@bowenxia bowenxia changed the title Update queries about execution table with timestamps Update C* queries about execution table with timestamps Jan 7, 2025
@@ -725,10 +728,10 @@ func (db *cdb) InsertReplicationTask(ctx context.Context, tasks []*nosqlplugin.R
shardID := shardCondition.ShardID
batch := db.session.NewBatch(gocql.LoggedBatch).WithContext(ctx)
for _, task := range tasks {
createReplicationTasks(batch, shardID, task.DomainID, task.WorkflowID, []*nosqlplugin.ReplicationTask{task})
createReplicationTasks(batch, shardID, task.DomainID, task.WorkflowID, []*nosqlplugin.ReplicationTask{task}, time.Now())
Copy link
Member

Choose a reason for hiding this comment

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

is the db.timesource available for these too?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. Update it.
But why is db.timesource.now() better than time.Now() ?

Copy link

codecov bot commented Jan 7, 2025

Codecov Report

Attention: Patch coverage is 97.56098% with 2 lines in your changes missing coverage. Please review.

Project coverage is 81.61%. Comparing base (e369936) to head (720521b).
Report is 12 commits behind head on master.

Files with missing lines Patch % Lines
...ence/nosql/nosqlplugin/cassandra/workflow_utils.go 96.55% 2 Missing ⚠️
Files with missing lines Coverage Δ
...ersistence/nosql/nosqlplugin/cassandra/workflow.go 100.00% <100.00%> (ø)
...ence/nosql/nosqlplugin/cassandra/workflow_utils.go 91.39% <96.55%> (+0.12%) ⬆️

... and 19 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e369936...720521b. Read the comment docs.

@@ -724,11 +727,12 @@ func (db *cdb) InsertReplicationTask(ctx context.Context, tasks []*nosqlplugin.R

shardID := shardCondition.ShardID
batch := db.session.NewBatch(gocql.LoggedBatch).WithContext(ctx)
timeStamp := db.timeSrc.Now()
Copy link
Contributor

Choose a reason for hiding this comment

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

My point of view:
It is incorrect. The field belongs to the ReplicationTask, so an SQL plugin could later support it.
I don't think db should have timeSrc field, this should be filled on the PersistenceManager level and pushed as is to the DB.

Copy link
Member

Choose a reason for hiding this comment

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

db object was using time.Now() in a few places since the beginning. While we were adding unit tests last year I replaced all time.Now()s with a db.timeSrc.Now() so the generated queries can be validated in the tests. This PR is following same pattern.
What you suggest is valid I think. The timestamp should be determined by the upper layer PersistentManager and the db is purely translating the entity records to DB queries without adding anything else on top. However that requires some refactoring. I don't think is is a source of bug but it's just better isolation of responsibilities. Let's turn that into a github issue and label with #up-for-grab.

@bowenxia bowenxia merged commit e57792d into master Jan 10, 2025
20 checks passed
@bowenxia bowenxia deleted the xbowen/update_cassandra_query_with_timestamps/execution_table branch January 10, 2025 21:50
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.

4 participants