-
Notifications
You must be signed in to change notification settings - Fork 9.8k
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 dbSizeInUse to StatusResposne #9256
Conversation
etcdserver/etcdserverpb/rpc.proto
Outdated
@@ -911,6 +911,8 @@ message StatusResponse { | |||
uint64 raftAppliedIndex = 7; | |||
// errors contains alarm/health information and status. | |||
repeated string errors = 8; | |||
// dbSize is the size of the backend database logically in use, in bytes, of the responding member. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/dbSize/dbSizeInUse/
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think we should add this as a metrics too. not just putting this into the status response.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
Also added a metrics.
@@ -300,10 +300,13 @@ func (s *store) Restore(b backend.Backend) error { | |||
} | |||
|
|||
func (s *store) restore() error { | |||
reportDbTotalSizeInBytesMu.Lock() | |||
b := s.b |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't find a particular reason to procted b := s.b
with the mutex. Let me know if I overlooked something.
eb5c4b5
to
fef9309
Compare
internal/mvcc/backend/backend.go
Outdated
@@ -54,6 +54,7 @@ type Backend interface { | |||
Hash(ignores map[IgnoreKey]struct{}) (uint32, error) | |||
// Size returns the current size of the backend. | |||
Size() int64 | |||
SizeInUse() int64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment on this interface method?
look good to me overall! we need to update https://github.com/coreos/etcd/blob/master/Documentation/op-guide/maintenance.md#defragmentation to mention the in-use-db-size to identify if a defrag is needed. |
Also update changelog https://github.com/coreos/etcd/blob/master/CHANGELOG-3.4.md? e.g. https://github.com/coreos/etcd/blob/master/CHANGELOG-3.3.md#addedmetrics Thanks! |
4a8ccda
to
03054b8
Compare
Thanks for your comments. Updated the code (just let me know or overwrite in case it has English errors). I'm wondering if we want to show the value by |
Let us do it in another PR? |
Got it. Somehow a test failed due to timeout. Probably #9086. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Thanks! Glad to see the data made available both as a metric and status field.
One minor grammer nit.
CHANGELOG-3.4.md
Outdated
@@ -51,6 +51,8 @@ | |||
- Add [`raftAppliedIndex` field to `etcdserverpb.StatusResponse`](https://github.com/coreos/etcd/pull/9176) for current Raft applied index. | |||
- Add [`errors` field to `etcdserverpb.StatusResponse`](https://github.com/coreos/etcd/pull/9206) for server-side error. | |||
- e.g. `"etcdserver: no leader", "NOSPACE", "CORRUPT"` | |||
- Add [`dbSizeInUse` field to `etcdserverpb.StatusResponse`](https://github.com/coreos/etcd/pull/9256) for actual DB size after compaction. | |||
- Also exposed as metrics `etcd_debugging_mvcc_db_total_size_in_use_in_bytes` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/metrics/metric
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Fixed.
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.
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.
For #9222.