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

tools: update descriptions of handling sharding ddl locks manually #876

Merged
merged 14 commits into from
Feb 11, 2019
Prev Previous commit
Next Next commit
tools/dm: update wording, format, address comments
  • Loading branch information
lilin90 authored Feb 11, 2019
commit 8cca829e815c3a952050d8fc79ffd83c53df0374
60 changes: 30 additions & 30 deletions tools/dm/manually-handling-sharding-ddl-locks.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ DM uses the sharding DDL lock to ensure operations are performed in the correct

### `show-ddl-locks`

Query the current DDL lock information on `DM-master`.
This command queries the current DDL lock information on `DM-master`.

#### Command usage

```bash
show-ddl-locks [--worker=127.0.0.1:8262] [task-name]
```

#### Variables description
#### Arguments description

- `worker`: flag; string; `--worker`; optional; can be specified multiple times; if not being specified, query the lock information related to all DM-workers; if being specified, query the lock information related only to the specified DM-worker.
- `task-name`: non-flag; string; optional; if not being specified, query the lock information related to all tasks; if being specified, query the lock information related only to the specified task.
- `worker`: flag; string; `--worker`; optional; can be specified multiple times; if it is not specified, this command queries the lock information related to all DM-workers; if it is specified, this command queries the lock information related only to the specified DM-worker.
- `task-name`: non-flag; string; optional; if it is not specified, this command queries the lock information related to all tasks; if it is specified, this command queries the lock information related only to the specified task.

#### Example of results

Expand Down Expand Up @@ -58,68 +58,68 @@ show-ddl-locks [--worker=127.0.0.1:8262] [task-name]

### `unlock-ddl-lock`

Actively ask `DM-master` to unlock the specified DDL lock, including asking the owner to execute the DDL, asking all other DM-workers that are not the owner to skip the DDL, and removing the lock information on `DM-master`.
This command actively asks `DM-master` to unlock the specified DDL lock, including asking the owner to execute the DDL, asking all other DM-workers that are not the owner to skip the DDL, and removing the lock information on `DM-master`.

#### Command usage

```bash
unlock-ddl-lock [--worker=127.0.0.1:8262] [--owner] [--force-remove] <lock-ID>
```

#### Variables description
#### Arguments description

- `worker`: flag; string; `--worker`; optional; can be specified multiple times; if not being specified, send requests for all DM-workers (except for the owner) that are waiting for the lock to skip the DDL; if being specified, send requests only for the specified DM-worker to skip the DDL
- `owner`: flag; string; `--owner`; optional; if not being specified, request for the default owner (the owner in the result of `show-ddl-locks`) to execute the DDL; if being specified, request for the DM-worker (the alternative of the default owner) to execute the DDL
- `force-remove`: flag; boolean; `--force-remove`; optional; if not being specified, remove the lock information only when the owner succeeds to execute the DDL; if being specified, compulsorily remove the lock information even though the owner fails to execute the DDL (after doing this you will not be able to query or operate on the lock again)
- `lock-ID`: non-flag; string; required; specify the ID of the DDL lock which needs to be unlocked (the `ID` in the result of `show-ddl-locks`)
- `worker`: flag; string; `--worker`; optional; it can be specified multiple times; if it is not specified, this command sends requests for all DM-workers (except for the owner) that are waiting for the lock to skip the DDL; if it is specified, this command sends requests only for the specified DM-worker to skip the DDL.
- `owner`: flag; string; `--owner`; optional; if it is not specified, this command requests for the default owner (the owner in the result of `show-ddl-locks`) to execute the DDL; if it is specified, this command requests for the DM-worker (the alternative of the default owner) to execute the DDL.
- `force-remove`: flag; boolean; `--force-remove`; optional; if it is not specified, this command removes the lock information only when the owner succeeds to execute the DDL; if it is specified, this command forcefully removes the lock information even though the owner fails to execute the DDL (after doing this you will not be able to query or operate on the lock again).
- `lock-ID`: non-flag; string; required; it specifies the ID of the DDL lock that needs to be unlocked (the `ID` in the result of `show-ddl-locks`).

#### Example of results

```bash
» unlock-ddl-lock test-`shard_db`.`shard_table`
{
"result": true, # the result of the unlocking operation
"msg": "", # the additional message for the failure to unlock the lock
"workers": [ # the result list of the DDL execution/skipping operation of each DM-worker
"result": true, # The result of the unlocking operation.
"msg": "", # The additional message for the failure to unlock the lock.
"workers": [ # The result list of the executing or skipping DDL operation of each DM-worker.
{
"result": true, # the result of the DDL execution/skipping operation
"worker": "127.0.0.1:8262", # the address of the DM-worker (the DM-worker ID)
"msg": "" # the additional message for the failure to the DDL execution/skipping operation of each DM-worker
"result": true, # The result of the executing or skipping DDL operation.
"worker": "127.0.0.1:8262", # The DM-worker ID.
"msg": "" # The reasons why the DM-worker failed to execute or skip the DDL statement.
}
]
}
```

### `break-ddl-lock`

Actively ask the DM-worker to compulsorily break the DDL lock that is to be unlocked, including asking the DM-worker to execute/skip the DDL and removing the DDL lock information on the DM-worker.
This command actively asks the DM-worker to forcefully break the DDL lock that is to be unlocked, including asking the DM-worker to execute/skip the DDL and removing the DDL lock information on the DM-worker.

#### Command usage

```bash
break-ddl-lock <--worker=127.0.0.1:8262> [--remove-id] [--exec] [--skip] <task-name>
```

#### Variables description
#### Arguments description

- `worker`: flag; string; `--worker`; required; specify the DM-worker which needs to execute the breaking operation
- `remove-id`: flag; string; `--remove-id`; optional; if being specified, it should be the ID of some DDL lock; if not being specified, remove the corresponding DDL lock information only when the breaking operation succeeds; if being specified, compulsorily remove the DDL lock information
- `exec`: flag; boolean; `--exec`; optional; cannot be specified simultaneously with the `--skip` parameter; if being specified, ask the DM-worker to execute the corresponding DDL of the lock
- `skip`: flag; boolean; `--skip`; optional; cannot be specified simultaneously with the `--exec` parameter; if being specified, ask the DM-worker to skip the corresponding DDL of the lock
- `task-name`: non-flag; string; required; specify the name of the task containing the lock that is going to execute the breaking operation (you can check if a task contains the lock via [query-status](../../tools/dm/query-status.md))
- `worker`: flag; string; `--worker`; required; it specifies the DM-worker that needs to execute the breaking operation.
- `remove-id`: deprecated.
- `exec`: flag; boolean; `--exec`; optional; cannot be specified simultaneously with the `--skip` parameter; if it is specified, this command asks the DM-worker to execute the corresponding DDL of the lock.
- `skip`: flag; boolean; `--skip`; optional; cannot be specified simultaneously with the `--exec` parameter; if it is specified, this command asks the DM-worker to skip the corresponding DDL of the lock.
- `task-name`: non-flag; string; required; it specifies the name of the task containing the lock that is going to execute the breaking operation (you can check whether a task contains the lock via [query-status](../../tools/dm/query-status.md)).

#### Example of results

```bash
» break-ddl-lock -w 127.0.0.1:8262 --exec test
{
"result": true, # the result of the lock breaking operation
"msg": "", # the additional message for the failure to the lock breaking operation
"workers": [ # the list of DM-workers which break the lock (currently the lock can be broken by only one DM-worker at a single operation)
"result": true, # The result of the lock breaking operation.
"msg": "", # The reason why the breaking lock operation failed.
"workers": [ # The list of DM-workers which break the lock (currently the lock can be broken by only one DM-worker at a single operation).
{
"result": false, # the result of the lock breaking operation by the DM-worker
"worker": "127.0.0.1:8262", # the address of the DM-worker (the DM-worker ID)
"msg": "" # the additional message for the failure to the lock breaking operation by the DM-worker
"result": false, # The result of the lock breaking operation by the DM-worker.
"worker": "127.0.0.1:8262", # The DM-worker ID.
"msg": "" # The reason why the DM-worker failed to break the lock.
}
]
}
Expand Down Expand Up @@ -206,7 +206,7 @@ The operation processes of MySQL and DM are as follows:
6. Use `unlock-dll-lock` to ask `DM-master` to actively unlock the DDL lock.
- If the owner of the DDL lock has gone offline, you can use the parameter `--owner` to specify another DM-worker as the new owner to execute the DDL.
- If any DM-worker reports an error, `result` will be set to `false`, and at this point you should check carefully if the errors of each DM-worker is acceptable and within expectations.
- DM-workers that have gone offline will return the error `rpc error: code = Unavailable`, which is within expectations and can be neglected; but if other online DM-workers return errors, then you should deal with them based on the scenario.
- DM-workers that have gone offline will return the error `rpc error: code = Unavailable`, which is within expectations and can be neglected; but if other online DM-workers return errors, then you should deal with them based on the scenario.

```bash
» unlock-ddl-lock test-`shard_db`.`shard_table`
Expand Down