Skip to content

Commit

Permalink
tdbg: default --dlq-version to v2 instead of v1 (temporalio#6393)
Browse files Browse the repository at this point in the history
## What changed?
<!-- Describe what has changed in this PR -->
tdbg: default --dlq-version to v2 instead of v1

## Why?
<!-- Tell your future self why have you made these changes -->

## How did you test it?
<!-- How have you verified this change? Tested locally? Added a unit
test? Checked in staging env? -->
unit tests

## Potential risks
<!-- Assuming the worst case, what can be broken when deploying this
change to production? -->

## Documentation
<!-- Have you made sure this change doesn't falsify anything currently
stated in `docs/`? If significant
new behavior is added, have you described that in `docs/`? -->

## Is hotfix candidate?
<!-- Is this PR a hotfix candidate or does it require a notification to
be sent to the broader community? (Yes/No) -->
  • Loading branch information
justinp-tt authored Aug 9, 2024
1 parent d63b9d5 commit ee64c4e
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 19 deletions.
12 changes: 6 additions & 6 deletions docs/admin/dlq.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ From the task type, get the corresponding DLQ type from this map:
4. visibility: 4

You can list the DLQ messages using the command:
`tdbg dlq --dlq-version v2 read --dlq-type {type}`. Substitute `{type}` with the integer value from step 3.
`tdbg dlq read --dlq-type {type}`. Substitute `{type}` with the integer value from step 3.
You can specify the maximum message ID to read using `--last-message-id` flag.
In case of replication tasks, you can specify the source cluster using the flag `--cluster`.

Search `Marking task as terminally failed, will send to DLQ` in logs and find the terminal error that caused the task to be enqueued to the DLQ.

If you can't find the logs, you can list all DLQs using the command `tdbg dlq --dlq-version v2 list` and find non-empty queues.
If you can't find the logs, you can list all DLQs using the command `tdbg dlq list` and find non-empty queues.
This command will list all queues in the decreasing order of message count.

Now these DLQ tasks can either be purged (removed from the DLQ), or merged (re-enqueued to the original queue which will
Expand All @@ -52,20 +52,20 @@ cause them to be retried).
## Resolution

### Deleting Tasks
To purge a message, execute the command `tdbg dlq --dlq-version v2 purge --dlq-type {type} --last-message-id {message_id}`.
To purge a message, execute the command `tdbg dlq purge --dlq-type {type} --last-message-id {message_id}`.
Note that this command will purge all messages with an ID less than or equal to the specified `message_id`.
The output of this command will have a job token which can be used to manage the purge job.
Before executing this command, you can list the messages in the queue using the command mentioned in step 6 above to make sure more messages are not purged by mistake.

### Retrying Tasks
To merge a message, execute the command `tdbg dlq --dlq-version v2 merge --dlq-type {type} --last-message-id {message_id}`.
To merge a message, execute the command `tdbg dlq merge --dlq-type {type} --last-message-id {message_id}`.
This command will merge all messages with an ID less than or equal to `message_id` back into the original queue for reprocessing.
The output of this command will have a job token that can be used to manage the merge job.

Once merge or purge command is executed, it will create a DLQ job which will process the DLQ messages.
You can get the status of this job using the command `tdbg dlq --dlq-version v2 job describe --job-token {job-token}`.
You can get the status of this job using the command `tdbg dlq job describe --job-token {job-token}`.
The value of job-token will be printed in the output of merge and purge commands.
The output of the describe command will have details like the last processed message ID, number of messages processed, etc.

### Cancelling Jobs
If you want to cancel a specific DLQ job, you can execute the command `tdbg dlq --dlq-version v2 job cancel --job-token {job-token} --reason {reason}`.
If you want to cancel a specific DLQ job, you can execute the command `tdbg dlq job cancel --job-token {job-token} --reason {reason}`.
7 changes: 0 additions & 7 deletions tests/dlq.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,6 @@ func (s *DLQSuite) TestReadArtificialDLQTasks() {
"tdbg",
"--" + tdbg.FlagYes,
"dlq",
"--" + tdbg.FlagDLQVersion, "v2",
"read",
"--" + tdbg.FlagDLQType, strconv.Itoa(tasks.CategoryTransfer.ID()),
"--" + tdbg.FlagCluster, sourceCluster,
Expand Down Expand Up @@ -525,7 +524,6 @@ func (s *DLQSuite) purgeMessages(ctx context.Context, maxMessageIDToDelete int64
"tdbg",
"--" + tdbg.FlagYes,
"dlq",
"--" + tdbg.FlagDLQVersion, "v2",
"purge",
"--" + tdbg.FlagDLQType, strconv.Itoa(tasks.CategoryTransfer.ID()),
"--" + tdbg.FlagLastMessageID, strconv.FormatInt(maxMessageIDToDelete, 10),
Expand Down Expand Up @@ -569,7 +567,6 @@ func (s *DLQSuite) mergeMessagesWithoutBlocking(ctx context.Context, maxMessageI
"tdbg",
"--" + tdbg.FlagYes,
"dlq",
"--" + tdbg.FlagDLQVersion, "v2",
"merge",
"--" + tdbg.FlagDLQType, strconv.Itoa(tasks.CategoryTransfer.ID()),
"--" + tdbg.FlagLastMessageID, strconv.FormatInt(maxMessageID, 10),
Expand All @@ -595,7 +592,6 @@ func (s *DLQSuite) readDLQTasks(ctx context.Context) []tdbgtest.DLQMessage[*pers
"tdbg",
"--" + tdbg.FlagYes,
"dlq",
"--" + tdbg.FlagDLQVersion, "v2",
"read",
"--" + tdbg.FlagDLQType, strconv.Itoa(tasks.CategoryTransfer.ID()),
"--" + tdbg.FlagOutputFilename, file.Name(),
Expand All @@ -610,7 +606,6 @@ func (s *DLQSuite) describeJob(ctx context.Context, token string) *adminservice.
args := []string{
"tdbg",
"dlq",
"--" + tdbg.FlagDLQVersion, "v2",
"job",
"describe",
"--" + tdbg.FlagJobToken, token,
Expand All @@ -630,7 +625,6 @@ func (s *DLQSuite) cancelJob(ctx context.Context, token string) *adminservice.Ca
args := []string{
"tdbg",
"dlq",
"--" + tdbg.FlagDLQVersion, "v2",
"job",
"cancel",
"--" + tdbg.FlagJobToken, token,
Expand All @@ -651,7 +645,6 @@ func (s *DLQSuite) listQueues(ctx context.Context) []*adminservice.ListQueuesRes
args := []string{
"tdbg",
"dlq",
"--" + tdbg.FlagDLQVersion, "v2",
"list",
"--" + tdbg.FlagPrintJSON,
}
Expand Down
4 changes: 0 additions & 4 deletions tools/tdbg/dlq_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,6 @@ type (

func (tc *dlqTestCase) Run(t *testing.T, firstAppRun chan struct{}) {
faultyAdminClient := &fakeAdminClient{err: errors.New("did not expect client to be used")}
// v2 by default
if tc.version == "" {
tc.version = "v2"
}
p := dlqTestParams{
dlqVersion: tc.version,
dlqType: strconv.Itoa(tasks.CategoryTransfer.ID()),
Expand Down
2 changes: 1 addition & 1 deletion tools/tdbg/tdbg_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func getCommands(
&cli.StringFlag{
Name: FlagDLQVersion,
Usage: "Version of DLQ to manage, options: v1, v2",
Value: "v1",
Value: "v2",
},
},
},
Expand Down
1 change: 0 additions & 1 deletion tools/tdbg/tdbgtest/output_parsing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ func TestParseDLQMessages(t *testing.T) {
"tdbg",
"--" + tdbg.FlagYes,
"dlq",
"--" + tdbg.FlagDLQVersion, "v2",
"read",
"--" + tdbg.FlagDLQType, "1",
"--" + tdbg.FlagTargetCluster, "test-target-cluster",
Expand Down

0 comments on commit ee64c4e

Please sign in to comment.