Skip to content

Commit

Permalink
*: Add dbSizeInUse to StatusResposne
Browse files Browse the repository at this point in the history
Existing dbSize shows physically allocated DB size and the backend
(boltdb) won't shrink it after a compaction until a user runs the defrag command.
The new dbSizeInUse shows the DB size that excludes free pages created
by compactions so that users can see the actual DB usage. dbSize >=
dbSizeInUse is always true.
Note that dbSizeInUse shows a page-based size and not byte level usage.
  • Loading branch information
Iwasaki Yudai committed Jan 30, 2018
1 parent 1d99d38 commit 53b032a
Show file tree
Hide file tree
Showing 5 changed files with 299 additions and 238 deletions.
7 changes: 6 additions & 1 deletion Documentation/dev-guide/apispec/swagger/rpc.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -2164,7 +2164,12 @@
"type": "object",
"properties": {
"dbSize": {
"description": "dbSize is the size of the backend database, in bytes, of the responding member.",
"description": "dbSize is the size of the backend database physically allocated, in bytes, of the responding member.",
"type": "string",
"format": "int64"
},
"dbSizeInUse": {
"description": "dbSize is the size of the backend database logically in use, in bytes, of the responding member.",
"type": "string",
"format": "int64"
},
Expand Down
1 change: 1 addition & 0 deletions etcdserver/api/v3rpc/maintenance.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ func (ms *maintenanceServer) Status(ctx context.Context, ar *pb.StatusRequest) (
RaftIndex: ms.rg.Index(),
RaftTerm: ms.rg.Term(),
RaftAppliedIndex: ms.rg.AppliedIndex(),
DbSizeInUse: ms.bg.Backend().SizeInUse(),
}
if uint64(ms.rg.Leader()) == raft.None {
resp.Errors = append(resp.Errors, etcdserver.ErrNoLeader.Error())
Expand Down
Loading

0 comments on commit 53b032a

Please sign in to comment.