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

Too rapid geth.log file growth #16511

Open
osmaczko opened this issue Sep 30, 2024 · 8 comments
Open

Too rapid geth.log file growth #16511

osmaczko opened this issue Sep 30, 2024 · 8 comments

Comments

@osmaczko
Copy link
Contributor

osmaczko commented Sep 30, 2024

Problem

The general problem is that the geth.log file grows too rapidly, especially when the debug log level is enabled. The default geth.log rotation strategy in status-desktop is to maintain a single geth.log file with a size limit of 100MB, then overwrite it when the next output file reaches the same limit:

$ ll geth*
100M Sep 28 10:42 geth-2024-09-28T08-42-56.771.log
40M Sep 28 10:45 geth.log

For my main Status account with the debug log level enabled, it takes approximately 6 minutes for the rotation, which is far too quick.

status-go version: 74ae41154

Future Steps

  • identify extensive and excessive logs
  • consider disabling go-waku logs
  • consider moving some debug level logs to trace level
  • consider logging categories which can be configured at runtime
osmaczko referenced this issue in status-im/status-go Sep 30, 2024
Logs from `messenger_mailserver` occupy 40 out of 100MB of data in
my `geth.log`.

Instead of extending `logger` with many parameters, such as `chatIDs`,
`topic`, etc., the hash of those parameters is calucalted and kept as a
context.

iterates: #5889
@osmaczko
Copy link
Contributor Author

$ grep "github.com/waku-org/go-waku" geth-2024-09-28T08-42-56.771.log | wc -c | awk '{print $1 / (1024 * 1024) " MB"}'     
1.79132 MB
$ grep "github.com/status-im/status-go/wakuv2" geth-2024-09-28T08-42-56.771.log | wc -c | awk '{print $1 / (1024 * 1024) " MB"}'
48.1634 MB
$ grep "protocol/messenger_mailserver.go" geth-2024-09-28T08-42-56.771.log | wc -c | awk '{print $1 / (1024 * 1024) " MB"}'     
45.0911 MB

Most of the log size is coming from github.com/status-im/status-go/wakuv2 and protocol/messenger_mailserver.go, where the later is being fixed.

CC: @richard-ramos

@osmaczko
Copy link
Contributor Author

osmaczko commented Sep 30, 2024

I've done more grepping, the results:

Code location Size [MB]
github.com/status-im/status-go/wakuv2/waku.go 28.44
github.com/status-im/status-go/wakuv2/waku.go:1310 7.88
github.com/status-im/status-go/wakuv2/waku.go:1543 6.69
github.com/status-im/status-go/wakuv2/waku.go:1438 6.53
github.com/status-im/status-go/wakuv2/waku.go:1584 4.26
github.com/status-im/status-go/wakuv2/tracer.go 19

github.com/status-im/status-go/wakuv2/tracer.go seems to be fixed already status-im/status-go#5740

@richard-ramos
Copy link
Member

richard-ramos commented Sep 30, 2024

:1310 - Seems useful for debugging

		logger.Info("received waku2 store message",
			zap.Stringer("envelopeHash", envelope.Hash()),
			zap.String("pubsubTopic", query.PubsubTopic),
			zap.Int64p("timestamp", envelope.Message().Timestamp),

:1543 - This seems useful for debugging too

	logger := w.logger.With(
		zap.Any("messageType", msgType),
		zap.Stringer("envelopeHash", envelope.Hash()),
		zap.String("contentTopic", envelope.Message().ContentTopic),
		zap.Int64("timestamp", envelope.Message().GetTimestamp()),
	)

	logger.Debug("received new envelope")

:1438 - We can probably eliminate this one, as it is not really useful to log that

	w.logger.Debug("peer stats",
		zap.Int("peersCount", len(latestConnStatus.Peers)),
		zap.Any("stats", latestConnStatus))

:1584 - These can be probably eliminated (they're all part of waku.add)

		logger := w.logger.With(zap.String("envelopeHash", recvMessage.Hash().Hex()))
...
		logger.Debug("w envelope already cached")
...
		logger.Debug("cached w envelope")
...
		logger.Debug("immediately processing envelope")
...
		logger.Debug("posting event")

I think we can get rid of some of these bugs, but the first two are kind of useful when debugging whether a message is received or not. I wonder if we can add some other level like TRACE to the logs?

@richard-ramos
Copy link
Member

Seems like it should be possible?
uber-go/zap#680 (comment)

Wdyt, @osmaczko @igor-sirotin

@igor-sirotin
Copy link
Contributor

uber-go/zap#680 (comment)

I like the idea of Trace level in general 👍 (but we should be careful even with that one)

@osmaczko
Copy link
Contributor Author

Seems like it should be possible? uber-go/zap#680 (comment)

Wdyt, @osmaczko @igor-sirotin

We discussed the trace level in one of the meetings. The conclusion was that with the trace level, we could end up having the same problem, so it is better to implement categorized logging configurable at runtime. Examples of potential categories include "wallet," "waku," "messenger," "communities," etc. I believe it would be best to combine both, to be honest.

osmaczko referenced this issue in status-im/status-go Sep 30, 2024
Logs from `messenger_mailserver` occupy 40 out of 100MB of data in
my `geth.log`.

Instead of extending `logger` with many parameters, such as `chatIDs`,
`topic`, etc., the hash of those parameters is calucalted and kept as a
context.

iterates: #5889
adklempner referenced this issue in status-im/status-go Oct 1, 2024
Logs from `messenger_mailserver` occupy 40 out of 100MB of data in
my `geth.log`.

Instead of extending `logger` with many parameters, such as `chatIDs`,
`topic`, etc., the hash of those parameters is calucalted and kept as a
context.

iterates: #5889
@osmaczko osmaczko self-assigned this Oct 3, 2024
@osmaczko osmaczko transferred this issue from status-im/status-go Oct 11, 2024
@osmaczko
Copy link
Contributor Author

osmaczko commented Oct 14, 2024

Note to myself: historical reasons of why we use zap.Logger and geth.Logger and how they were merged together: status-im/status-go#1534

osmaczko added a commit to status-im/status-go that referenced this issue Oct 17, 2024
osmaczko added a commit to status-im/status-go that referenced this issue Dec 3, 2024
osmaczko added a commit to status-im/status-go that referenced this issue Dec 4, 2024
osmaczko added a commit to status-im/status-go that referenced this issue Dec 4, 2024
osmaczko added a commit to status-im/status-go that referenced this issue Dec 4, 2024
This ensures waku node logs remain at INFO level, even if the global
logging level is set lower (e.g. DEBUG). To enable waku logs at a
specific level, one can execute:
`wakuext_setLogNamespaces([{"logNamespaces": "wakunode:debug"}])`.

iterates: status-im/status-desktop#16511
osmaczko added a commit to status-im/status-go that referenced this issue Dec 5, 2024
This ensures waku node logs remain at INFO level, even if the global
logging level is set lower (e.g. DEBUG). To enable waku logs at a
specific level, one can execute:
`wakuext_setLogNamespaces([{"logNamespaces": "wakunode:debug"}])`.

iterates: status-im/status-desktop#16511
@osmaczko osmaczko moved this from In Progress to Code Review in Status Desktop/Mobile Board Dec 5, 2024
@osmaczko
Copy link
Contributor Author

osmaczko commented Dec 5, 2024

Waiting for status-im/status-mobile#21758 to merge the last missing piece status-im/status-go#6164.

osmaczko added a commit to status-im/status-go that referenced this issue Dec 6, 2024
This ensures waku node logs remain at INFO level, even if the global
logging level is set lower (e.g. DEBUG). To enable waku logs at a
specific level, one can execute:
`wakuext_setLogNamespaces([{"logNamespaces": "wakunode:debug"}])`.

iterates: status-im/status-desktop#16511
@iurimatias iurimatias added the bug Something isn't working label Jan 10, 2025
@iurimatias iurimatias added this to the 2.34.0 Beta milestone Feb 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Code Review
Development

No branches or pull requests

4 participants