all: querylog size memory

This commit is contained in:
Stanislav Chzhen 2023-12-25 20:06:09 +03:00
parent ad147ac7b6
commit 0b17cfc424
4 changed files with 12 additions and 7 deletions

View File

@ -58,6 +58,7 @@ NOTE: Add new changes BELOW THIS COMMENT.
### Fixed
- Zero value in `querylog.size_memory` disables logging ([#6570]).
- Load balancing algorithm stuck on a single server ([#6480]).
- Statistics for 7 days displayed as 168 hours on the dashboard.
- Pre-filling the Edit static lease window with data ([#6534]).
@ -71,6 +72,7 @@ NOTE: Add new changes BELOW THIS COMMENT.
[#6534]: https://github.com/AdguardTeam/AdGuardHome/issues/6534
[#6541]: https://github.com/AdguardTeam/AdGuardHome/issues/6541
[#6545]: https://github.com/AdguardTeam/AdGuardHome/issues/6545
[#6570]: https://github.com/AdguardTeam/AdGuardHome/issues/6570
<!--
NOTE: Add new changes ABOVE THIS COMMENT.

View File

@ -267,7 +267,7 @@ type queryLogConfig struct {
// MemSize is the number of entries kept in memory before they are flushed
// to disk.
MemSize int `yaml:"size_memory"`
MemSize uint `yaml:"size_memory"`
// Enabled defines if the query log is enabled.
Enabled bool `yaml:"enabled"`

View File

@ -202,10 +202,10 @@ func (l *queryLog) Add(params *AddParams) {
defer l.confMu.RUnlock()
isEnabled, fileIsEnabled = l.conf.Enabled, l.conf.FileEnabled
memSize = l.conf.MemSize
memSize = int(l.conf.MemSize)
}()
if !isEnabled || memSize == 0 {
if !isEnabled {
return
}

View File

@ -63,7 +63,7 @@ type Config struct {
// MemSize is the number of entries kept in a memory buffer before they are
// flushed to disk.
MemSize int
MemSize uint
// Enabled tells if the query log is enabled.
Enabled bool
@ -143,14 +143,17 @@ func newQueryLog(conf Config) (l *queryLog, err error) {
}
}
if conf.MemSize < 0 {
return nil, errors.Error("memory size must be greater or equal to zero")
memSize := int(conf.MemSize)
if memSize == 0 {
// If query log is not diabled, we still need to write entries to a
// file. And all writing goes through a buffer.
memSize = 1
}
l = &queryLog{
findClient: findClient,
buffer: aghalg.NewRingBuffer[*logEntry](conf.MemSize),
buffer: aghalg.NewRingBuffer[*logEntry](memSize),
conf: &Config{},
confMu: &sync.RWMutex{},