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

Add TaskContext to tasks to be track e2e instant transfer information #204

Closed
wants to merge 3 commits into from

Conversation

hussainkarafallah
Copy link
Contributor

@hussainkarafallah hussainkarafallah commented Aug 9, 2024

Context

TwTasks is missing propagated context. For example if a service receives a REST call and registers a tw-task as a side effect. This task loses the context. Adding TaskContext to the tw_task_data table. Shall be good enough.

One complication here:
The data column has non null constraint. Adding the context to this table is problematic now. Before, tasks with null data were not inserting anything in that table. But now it's quite reasonable to assume we might have tasks with no data but with some context. For tasks with no data, adding a dummy data in db of 1 byte "®"

IF some team creates a tw-tasks with the payload of this letter only. They might run into issues.

Checklist

@hussainkarafallah hussainkarafallah requested a review from a team as a code owner August 9, 2024 03:44
@@ -58,6 +61,8 @@ public class TasksService implements ITasksService, GracefulShutdownStrategy, In
private IEnvironmentValidator environmentValidator;
@Autowired
private ICoreMetricsTemplate coreMetricsTemplate;
@Autowired(required = false)
private List<ITaskRegistrationDecorator> taskRegistrationInterceptors = new ArrayList<>();
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe taskRegistrationInterceptors > taskRegistrationDecorator

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let's keep decorator, usually decorator gives expectation that you are modifying something
interceptor not really it means you just react

mdcService.put(request.getTaskId(), 0L);
mdcService.putType(request.getType());
mdcService.putSubType(request.getSubType());

for (ITaskRegistrationDecorator interceptor : taskRegistrationInterceptors) {
request = interceptor.intercept(request);
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe instead request = decorator.decorate(request);

Copy link
Contributor Author

@hussainkarafallah hussainkarafallah Aug 9, 2024

Choose a reason for hiding this comment

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

oh yeah sure, this was after rename :3

coreMetricsTemplate.registerDaoTaskDataSerialization(request.getType(), data.length, serializedData.getData().length);
}

byte[] data = request.getData() == null ? NULL_BLOB : request.getData();
Copy link
Contributor

Choose a reason for hiding this comment

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

We should avoid this block, if both data and context are null / empty.
Just to avoid one more record in database for lightweight tasks.


public interface ITaskRegistrationDecorator {

AddTaskRequest intercept(AddTaskRequest request);
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe intercept > decorate.

task_id BINARY(16) PRIMARY KEY NOT NULL,
data_format INT NOT NULL,
data LONGBLOB NOT NULL,
task_context_format SMALLINT,
Copy link
Contributor

Choose a reason for hiding this comment

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

Ideally the fixed length fields should be at the beginning of the table.
But it does not matter too much.

Besides we can probably only add columns to the end.

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.

2 participants