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

*: Add dbSizeInUse to StatusResposne #9256

Merged
merged 1 commit into from
Feb 1, 2018
Merged

Conversation

yudai
Copy link
Contributor

@yudai yudai commented Jan 30, 2018

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.

@@ -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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/dbSize/dbSizeInUse/?

Copy link
Contributor

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.

Copy link
Contributor Author

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
Copy link
Contributor Author

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.

@yudai yudai force-pushed the actual_db_size branch 2 times, most recently from eb5c4b5 to fef9309 Compare January 31, 2018 03:35
@@ -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
Copy link
Contributor

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?

@xiang90
Copy link
Contributor

xiang90 commented Jan 31, 2018

@yudai

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.

@gyuho
Copy link
Contributor

gyuho commented Jan 31, 2018

@yudai yudai force-pushed the actual_db_size branch 2 times, most recently from 4a8ccda to 03054b8 Compare January 31, 2018 19:23
@yudai
Copy link
Contributor Author

yudai commented Jan 31, 2018

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 endpoint status as well?

@xiang90
Copy link
Contributor

xiang90 commented Feb 1, 2018

I'm wondering if we want to show the value by endpoint status as well?

Let us do it in another PR?

@xiang90
Copy link
Contributor

xiang90 commented Feb 1, 2018

LGTM. Defer to @jpbetz and @gyuho

@yudai
Copy link
Contributor Author

yudai commented Feb 1, 2018

Let us do it in another PR?

Got it.

Somehow a test failed due to timeout. Probably #9086.

Copy link
Contributor

@jpbetz jpbetz left a 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`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/metrics/metric

Copy link
Contributor Author

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.
@xiang90 xiang90 merged commit 4127882 into etcd-io:master Feb 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants