Skip to content

box.error.READONLY new attributes #2444

Closed
@TarantoolBot

Description

@TarantoolBot

Product: Tarantool
Since: 2.10.0-beta2
Audience/target: Tarantool users
Root document: https://www.tarantool.io/en/doc/latest/reference/reference_lua/box_error/error_object/
SME: @ Gerold103

Related to: #2445

Details

[from the commit message]:
ER_READONLY used not to have any details about the exact reason
why the instance is read-only. The patch changes that by adding
new fields into the error which explain why the error happened and
even help to avoid it for next requests.

[input from the TarantoolBot]:
Users could see the error code as box.error.READONLY in .code
field of an error object. The error didn't have any other
attributes except common ones like 'type'.

Now from the box.error.READONLY error users can see why it
happened. The reasons can be the following:

  • The instance has box.cfg.read_only = true. Then the READONLY
    error has at least these fields:
tarantool> err:unpack()
---
- reason: config
  code: 7
  type: ClientError
...
  • The instance is an orphan. It enters that state if number of
    connected replicas is < box.cfg.replication_connect_quorum. Then
    READONLY error has at least these fields:
tarantool> err:unpack()
---
- reason: orphan
  code: 7
  type: ClientError
...
  • The synchro queue has an owner which is not the given instance.
    It usually happens if synchronous replication is used and there is
    another instance who called box.ctl.promote(). Then READONLY
    error has at least these fields:
tarantool> err:unpack()
---
- queue_owner_id: <box.info.id of the queue owner>
  queue_owner_uuid: <box.info.uuid of the queue owner>
  reason: synchro
  term: <last known box.info.election.term of the owner>
  code: 7
  type: ClientError
...

Note than queue_owner_uuid sometimes might be not present.

  • The instance has box.cfg.election_mode not off and it is not
    a leader. Then READONLY error has at least these fields:
tarantool> err:unpack()
---
- state: <box.info.election.state of this instance>
  leader_id: <box.info.id of the leader>
  leader_uuid: <box.info.uuid of the leader>
  reason: election
  term: <box.info.election.term of this instance>
  code: 7
  type: ClientError
...

leader_id and leader_uuid might be absent if the leader is not
known. For example, an election is still in progress. Note, than
leader_uuid sometimes might be not present even if leader_id
is.

If multiple reasons are true at the same time, then only one is
returned in the following order of preference: election, synchro,
config, orphan.
Requested by @Gerold103 in tarantool/tarantool@f57b314

ToDo

  • Describe the new field of the error object -- .reason -- that is for the ER_READONLY error only.
  • Make a link to the description of the box.info.ro_reason ([3pt] box.info.ro_reason #2445): error_object.reason is the same as the box.info.ro_reason at the moment of throwing the error.

Metadata

Metadata

Assignees

Labels

2.10errorsfeatureA new functionalityreference[location] Tarantool manual, Reference part

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions