Skip to content

Incorrect and overflowed db.Metrics().DiskSpaceUsage() #4811

@carsonip

Description

@carsonip

db.Metrics().DiskSpaceUsage() can return an incorrect number which is impossibly large (close to math.Uint64), and appears to be a negative int64 converted to uint64.

db.Metrics().String()

      |                             |       |       |   ingested   |     moved    |    written   |       |    amp
level | tables  size val-bl vtables | score |   in  | tables  size | tables  size | tables  size |  read |   r   w
------+-----------------------------+-------+-------+--------------+--------------+--------------+-------+---------
    0 |     0     0B     0B       0 |  0.00 | 6.4MB |     0     0B |     0     0B |     7  4.5MB |    0B |   0  0.7
    1 |     0     0B     0B       0 |  0.00 |    0B |     0     0B |     0     0B |     0     0B |    0B |   0  0.0
    2 |     0     0B     0B       0 |  0.00 |    0B |     0     0B |     0     0B |     0     0B |    0B |   0  0.0
    3 |     0     0B     0B       0 |  0.00 |    0B |     0     0B |     0     0B |     0     0B |    0B |   0  0.0
    4 |     0     0B     0B       0 |  0.00 |    0B |     0     0B |     0     0B |     0     0B |    0B |   0  0.0
    5 |     0     0B     0B       0 |  0.00 |    0B |     0     0B |     0     0B |     0     0B |    0B |   0  0.0
    6 |     3  5.1MB     0B       0 |     - | 4.5MB |     0     0B |     1   95KB |     6   13MB |  14MB |   1  2.9
total |     3  5.1MB     0B       0 |     - | 6.4MB |     0     0B |     1   95KB |    13   24MB |  14MB |   1  3.7
-------------------------------------------------------------------------------------------------------------------
WAL: 1 files (40KB)  in: 5.1MB  written: 6.4MB (26%!o(MISSING)verhead)
Flushes: 6
Compactions: 6  estimated debt: 0B  in progress: 0 (0B)
             default: 3  delete: 1  elision: 1  move: 1  read: 0  tombstone-density: 0  rewrite: 0  copy: 0  multi-level: 0
MemTables: 1 (2.0MB)  zombie: 1 (2.0MB)
Zombie tables: 0 (0B, local: 0B)
Backing tables: 0 (0B)
Virtual tables: 0 (0B)
Local tables size: 5.1MB
Compression types: none: 3
Block cache: 168 entries (369KB)  hit rate: 97.0%!
(MISSING)Table cache: 3 entries (2.2KB)  hit rate: 100.0%!
(MISSING)Secondary cache: 0 entries (0B)  hit rate: 0.0%!
(MISSING)Snapshots: 0  earliest seq num: 0
Table iters: 0
Filter utility: 98.9%!
(MISSING)Ingestions: 0  as flushable: 0 (0B in 0 tables)
Cgo memory usage: 37MB  block cache: 753KB (data: 396KB, maps: 276KB, entries: 80KB)  memtables: 36MB

Custom breakdown of public fields used by DiskSpaceUsage

wal phy 1706827 obs phy 1707907
table local live 5313593 obs 18446744073700799630 zombie 0
compact in progress 0

Apparently the table local obsolete size is problematic.

Options used by this db

pebble.Options{
	FormatMajorVersion: pebble.FormatColumnarBlocks,
	MemTableSize:       2 << 20,
	Levels: []pebble.LevelOptions{
		{
			BlockSize:    2 << 10,
			Compression:  func() pebble.Compression { return pebble.NoCompression },
			FilterPolicy: bloom.FilterPolicy(10),
			FilterType:   pebble.TableFilter,
		},
	},
}

Steps to reproduce described in elastic/apm-server#17043

Jira issue: PEBBLE-467

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions