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

missing logs #2272

Closed
quchenyuan opened this issue Jun 29, 2020 · 9 comments · Fixed by #2306
Closed

missing logs #2272

quchenyuan opened this issue Jun 29, 2020 · 9 comments · Fixed by #2306
Assignees
Labels
component/loki keepalive An issue or PR that will be kept alive and never marked as stale. type/bug Somehing is not working as expected

Comments

@quchenyuan
Copy link

I test with a pod runs the following shell script:
`
#! /bin/bash

i=0
while true
do
d=$(date "+%Y-%m-%d %H:%M:%S.%N")
printf "%-10d %20s %-10s %s\n" $i "$d" "---" "$(cat ./text)"
sleep 0.1;
((i++));
done
`
./text is a file with a single line, which has a length of 25214

I query with logcli and found that some lines are missing:
`
2020-06-29T17:37:09+08:00 2020-06-29T17:37:09.788688333+08:00 stdout F 9 2020-06-29 09:37:09. ---
2020-06-29T17:37:09+08:00 2020-06-29T17:37:09.99691343+08:00 stdout F 11 2020-06-29 09:37:09. ---
2020-06-29T17:37:10+08:00 2020-06-29T17:37:10.100728939+08:00 stdout F 12 2020-06-29 09:37:10. ---

2020-06-29T17:37:10+08:00 2020-06-29T17:37:10.829034129+08:00 stdout F 19 2020-06-29 09:37:10. ---
2020-06-29T17:37:10+08:00 2020-06-29T17:37:10.932854453+08:00 stdout F 20 2020-06-29 09:37:10. ---
2020-06-29T17:37:11+08:00 2020-06-29T17:37:11.140982502+08:00 stdout F 22 2020-06-29 09:37:11. ---
`

and I checked the original log files, the number sequences are continuous.

Besides, no errors or exceptions are found in promtail logs.

Does anyone have a clue with this?

Originally posted by @quchenyuan in #246 (comment)

@cyriltovena
Copy link
Contributor

Hello, we need more information to help you.

Which client are you using to push log ? what configuration are you using ? Can you activate debug log for Loki and verify if anything stands out ? Which version are you using ?

Thanks !

@quchenyuan
Copy link
Author

I have 3 hosts: A, B, C ;the deploy architecture is :

image

I built loki and promtail from master branch(version master-e400b4b (branch: master, revision: e400b4b1):

config:
`
server:
http_listen_port: 9080
grpc_listen_port: 0

positions:
filename: /tmp/positions.yaml

clients:

scrape_configs:

  • job_name: cube
    static_configs:
    • targets:
      • localhost
        labels:
        path: /var/log/pods///*.log
        hostname: A
        pipeline_stages:
      • regex:
        source: filename
        expression: "(?:pods)/(?P\S+?)(?P\S+?)\S+?/(?P\S+?)/(?P\S+?.log)$"
      • labels:
        namespace:
        pod:
        container:
        file:
      • tenant:
        source: namespace
      • regex:
        expression: "^(?s)(?P\S+?) (?Pstdout|stderr) (?P\S+?) (?P.*)$"
      • timestamp:
        source: time
        format: RFC3339Nano
        relabel_configs:
      • source_labels: ['file']
        action: keep
        `

Besides, it only happens when the log is big. If I remove the ./text file context from the shell script, everything is fine.
printf "%-10d %20s %-10s\n" $i "$d" "---"

@cyriltovena
Copy link
Contributor

This architecture is neither the one we provide with helm nor tanka. You should start with those first. See if the issue persist.

@quchenyuan
Copy link
Author

quchenyuan commented Jul 7, 2020

By redirecting all entries of promtail/distributor/ingester to local files, I gradually narrowed the bug down to MemChunk serialise. Here is how I produced the probelm, ./pkg/chunkenc/memchunk.go:

func (hb *headBlock) serialise(pool WriterPool) ([]byte, error) { .... _=writeToLocal(hb.entries,"memChunkCut.log") ... }

`
func (c *MemChunk) cut() error {
...

b, err := c.head.serialise(c.writers)
if err != nil {
	return err
}

blk := block{
	b:                b,
	numEntries:       len(c.head.entries),
	mint:             c.head.mint,
	maxt:             c.head.maxt,
	uncompressedSize: c.head.size,
}

c.writeBlock(context.TODO(),blk)

...
`

So, I test with memchunk_test.go, the TestBlock function goes well. But when I use a longer str as in my case, tests failed. Here is how I reproduced the problem:

`

var line = "
Apr 16 18:34:16 Installed: python-kitchen-1.1.1-5.el7.noarchApr 16 18:34:16 Installed: libxml2-python-2.9.1-6.el7_2.3.x86_64Apr 16 18:34:17 Installed: yum-utils-1.1.31-46.el7_5.noarchApr 16 18:34:21 Installed: OpenIPMI-modalias-2.0.19-15.el7.x86_64Apr 16 18:34:21 Installed: ipmitool-1.8.18-5.el7.x86_64Apr 16 18:34:23 Installed: OpenIPMI-libs-2.0.19-15.el7.x86_64Apr 16 18:34:23 Installed: 1:net-snmp-libs-5.7.2-28.el7.x86_64Apr 16 18:34:23 Installed: OpenIPMI-2.0.19-15.el7.x86_64Apr 16 18:34:26 Installed: pubkey_manage-2.1-1.el7.centos.x86_64Apr 16 18:34:42 Updated: libgcc-4.8.5-28.el7_5.1.x86_64Apr 16 18:34:46 Updated: glibc-common-2.17-196.el7_4.2.x86_64Apr 16 18:34:46 Updated: glibc-2.17-196.el7_4.2.x86_64Apr 16 18:34:46 Updated: libcom_err-1.45.2.wc1-0.el7.x86_64Apr 16 18:34:46 Updated: krb5-libs-1.15.1-19.el7.x86_64Apr 16 18:34:47 Installed: ruby-libs-2.0.0.648-35.el7_6.x86_64Apr 16 18:34:48 Updated: python-libs-2.7.5-77.el7_6.x86_64Apr 16 18:34:48 Updated: python-2.7.5-77.el7_6.x86_64Apr 16 18:34:48 Installed: lm_sensors-libs-3.4.0-4.20160601gitf9185e5.el7.x86_64Apr 16 18:34:48 Installed: zlib-devel-1.2.7-17.el7.x86_64Apr 16 18:34:48 Installed: 2:libogg-1.3.0-7.el7.x86_64Apr 16 18:34:48 Installed: nettle-2.7.1-8.el7.x86_64Apr 16 18:34:48 Installed: libICE-1.0.9-9.el7.x86_64Apr 16 18:34:49 Installed: 14:libpcap-1.5.3-9.el7.x86_64Apr 16 18:34:49 Installed: mpfr-3.1.1-4.el7.x86_64Apr 16 18:34:49 Installed: libxslt-1.1.28-5.el7.x86_64Apr 16 18:34:49 Installed: libmpc-1.0.1-3.el7.x86_64Apr 16 18:34:49 Installed: libSM-1.2.2-2.el7.x86_64Apr 16 18:34:49 Installed: elfutils-libelf-devel-0.168-8.el7.x86_64Apr 16 18:34:49 Installed: 1:net-snmp-agent-libs-5.7.2-28.el7.x86_64Apr 16 18:34:49 Installed: 2:libpng-1.5.13-7.el7_2.x86_64Apr 16 18:34:49 Updated: freetype-2.8-14.el7.x86_64Apr 16 18:34:49 Installed: xz-devel-5.2.2-1.el7.x86_64Apr 16 18:34:49 Installed: fontpackages-filesystem-1.44-8.el7.noarchApr 16 18:34:49 Installed: dejavu-fonts-common-2.33-6.el7.noarchApr 16 18:34:50 Installed: dejavu-sans-fonts-2.33-6.el7.noarchApr 16 18:34:51 Installed: fontconfig-2.13.0-4.3.el7.x86_64Apr 16 18:34:51 Installed: libxml2-devel-2.9.1-6.el7_2.3.x86_64Apr 16 18:34:51 Installed: elfutils-devel-0.168-8.el7.x86_64Apr 16 18:34:52 Installed: cpp-4.8.5-28.el7_5.1.x86_64Apr 16 18:34:52 Installed: python-lxml-3.2.1-4.el7.x86_64Apr 16 18:34:52 Installed: python-javapackages-3.4.1-11.el7.noarchApr 16 18:34:52 Installed: javapackages-tools-3.4.1-11.el7.noarchApr 16 18:34:52 Installed: ldns-1.6.16-10.el7.x86_64Apr 16 18:34:52 Installed: 1:libvorbis-1.3.3-8.el7.x86_64Apr 16 18:34:52 Installed: flac-libs-1.3.0-5.el7_1.x86_64Apr 16 18:34:52 Installed: lm_sensors-devel-3.4.0-4.20160601gitf9185e5.el7.x86_64Apr 16 18:34:52 Installed: pyparsing-1.5.6-9.el7.noarchApr 16 18:34:52 Installed: systemtap-sdt-devel-3.1-3.el7.x86_64Apr 16 18:34:52 Installed: postgresql-libs-9.2.24-1.el7_5.x86_64Apr 16 18:34:53 Updated: libcurl-7.29.0-46.el7.x86_64Apr 16 18:34:53 Installed: libkadm5-1.15.1-19.el7.x86_64Apr 16 18:34:53 Installed: cyrus-sasl-2.1.26-21.el7.x86_64Apr 16 18:34:53 Updated: libss-1.45.2.wc1-0.el7.x86_64Apr 16 18:34:53 Installed: libcom_err-devel-1.45.2.wc1-0.el7.x86_64Apr 16 18:34:53 Updated: e2fsprogs-libs-1.45.2.wc1-0.el7.x86_64Apr 16 18:34:53 Updated: libgomp-4.8.5-28.el7_5.1.x86_64Apr 16 18:34:53 Installed: libcgroup-0.41-13.el7.x86_64Apr 16 18:34:53 Installed: perl-Data-Dumper-2.145-3.el7.x86_64Apr 16 18:34:54 Installed: libXau-1.0.8-2.1.el7.x86_64Apr 16 18:34:54 Installed: libxcb-1.12-1.el7.x86_64Apr 16 18:34:54 Installed: autogen-libopts-5.18-5.el7.x86_64Apr 16 18:34:54 Installed: glibc-headers-2.17-196.el7_4.2.x86_64Apr 16 18:34:54 Installed: glibc-devel-2.17-196.el7_4.2.x86_64Apr 16 18:34:54 Installed: gsm-1.0.13-11.el7.x86_64Apr 16 18:34:54 Installed: libsndfile-1.0.25-10.el7.x86_64Apr 16 18:34:55 Installed: trousers-0.3.14-2.el7.x86_64Apr 16 18:34:55 Installed: gnutls-3.3.26-9.el7.x86_64Apr 16 18:34:55 Installed: libjpeg-turbo-1.2.90-5.el7.x86_64Apr 16 18:34:55 Installed: libaio-0.3.109-13.el7.x86_64Apr 16 18:34:55 Installed: libevent-2.0.21-4.el7.x86_64Apr 16 18:35:13 Installed: unbound-libs-1.4.20-34.el7.x86_64Apr 16 18:35:13 Installed: gnutls-dane-3.3.26-9.el7.x86_64Apr 16 18:35:13 Installed: libyaml-0.1.4-11.el7_0.x86_64Apr 16 18:35:13 Installed: rubygem-psych-2.0.0-35.el7_6.x86_64Apr 16 18:35:13 Installed: rubygem-io-console-0.4.2-35.el7_6.x86_64Apr 16 18:35:13 Installed: rubygem-json-1.7.7-35.el7_6.x86_64Apr 16 18:35:13 Installed: rubygem-bigdecimal-1.2.0-35.el7_6.x86_64Apr 16 18:35:13 Installed: ruby-irb-2.0.0.648-34.el7_6.noarchApr 16 18:35:13 Installed: ruby-2.0.0.648-35.el7_6.x86_64Apr 16 18:35:13 Installed: rubygems-2.0.14.1-35.el7_6.noarchApr 16 18:35:13 Installed: rubygem-rdoc-4.0.0-35.el7_6.noarchApr 16 18:35:13 Installed: libasyncns-0.8-7.el7.x86_64Apr 16 18:35:13 Updated: iptables-1.4.21-18.2.el7_4.x86_64Apr 16 18:35:13 Installed: libdb-devel-5.3.21-20.el7.x86_64Apr 16 18:35:13 Installed: libX11-common-1.6.5-1.el7.noarchApr 16 18:35:14 Installed: libX11-1.6.5-1.el7.x86_64Apr 16 18:35:14 Installed: libXext-1.3.3-3.el7.x86_64Apr 16 18:35:14 Installed: libXi-1.7.9-1.el7.x86_64Apr 16 18:35:14 Installed: libXtst-1.2.3-1.el7.x86_64Apr 16 18:35:14 Installed: pulseaudio-libs-10.0-3.el7.x86_64Apr 16 18:35:14 Installed: libXrender-0.9.10-1.el7.x86_64Apr 16 18:35:14 Installed: libXcomposite-0.4.4-4.1.el7.x86_64Apr 16 18:35:14 Installed: giflib-4.1.6-9.el7.x86_64Apr 16 18:35:14 Installed: tzdata-java-2017c-1.el7.noarchApr 16 18:35:14 Installed: perl-Test-Harness-3.28-3.el7.noarchApr 16 18:35:14 Installed: popt-devel-1.13-16.el7.x86_64Apr 16 18:35:14 Installed: rpm-devel-4.11.3-25.el7.x86_64Apr 16 18:35:15 Installed: gdbm-devel-1.10-8.el7.x86_64Apr 16 18:35:15 Installed: perl-ExtUtils-Manifest-1.61-244.el7.noarchApr 16 18:35:15 Installed: 1:perl-ExtUtils-ParseXS-3.18-3.el7.noarchApr 16 18:35:15 Installed: perl-ExtUtils-MakeMaker-6.68-3.el7.noarchApr 16 18:35:15 Installed: perl-ExtUtils-Install-1.58-292.el7.noarchApr 16 18:35:15 Installed: 4:perl-devel-5.16.3-292.el7.x86_64Apr 16 18:35:15 Installed: mailcap-2.1.41-2.el7.noarchApr 16 18:35:15 Installed: libsepol-devel-2.5-6.el7.x86_64Apr 16 18:35:15 Installed: keyutils-libs-devel-1.5.8-3.el7.x86_64Apr 16 18:35:15 Installed: tcp_wrappers-devel-7.6-77.el7.x86_64Apr 16 18:35:15 Installed: libgpg-error-devel-1.12-3.el7.x86_64Apr 16 18:35:15 Installed: libgcrypt-devel-1.5.3-14.el7.x86_64Apr 16 18:35:15 Installed: pcre-devel-8.32-17.el7.x86_64Apr 16 18:35:15 Installed: libselinux-devel-2.5-11.el7.x86_64Apr 16 18:35:15 Installed: libverto-devel-0.2.5-4.el7.x86_64Apr 16 18:35:15 Installed: krb5-devel-1.15.1-19.el7.x86_64Apr 16 18:35:15 Installed: 1:openssl-devel-1.0.2k-8.el7.x86_64Apr 16 18:35:15 Installed: 1:net-snmp-devel-5.7.2-28.el7.x86_64Apr 16 18:35:15 Installed: libxslt-devel-1.1.28-5.el7.x86_64Apr 16 18:35:19 Installed: 1:java-1.6.0-openjdk-1.6.0.41-1.13.13.1.el7_3.x86_64Apr 16 18:35:19 Installed: iptables-services-1.4.21-18.2.el7_4.x86_64Apr 16 18:35:19 Installed: ruby-devel-2.0.0.648-35.el7_6.x86_64Apr 16 18:35:19 Installed: gnutls-utils-3.3.26-9.el7.x86_64Apr 16 18:35:19 Installed: blktrace-1.0.5-8.el7.x86_64Apr 16 18:35:21 Installed: gcc-4.8.5-28.el7_5.1.x86_64Apr 16 18:35:21 Installed: 1:net-snmp-5.7.2-28.el7.x86_64Apr 16 18:35:21 Installed: libcgroup-tools-0.41-13.el7.x86_64Apr 16 18:35:21 Updated: e2fsprogs-1.45.2.wc1-0.el7.x86_64Apr 16 18:35:21 Installed: cyrus-sasl-devel-2.1.26-21.el7.x86_64Apr 16 18:35:21 Updated: curl-7.29.0-46.el7.x86_64Apr 16 18:35:21 Installed: cyrus-sasl-sql-2.1.26-21.el7.x86_64Apr 16 18:35:22 Installed: 14:tcpdump-4.9.0-5.el7.ucloud.x86_64Apr 16 18:35:22 Installed: iftop-1.0-0.14.pre4.el7.x86_64Apr 16 18:35:22 Installed: sysstat-10.1.5-12.el7.x86_64Apr 16 18:35:22 Installed: scapy-2.3.3-1.el7.noarchApr 16 18:35:22 Installed: python-devel-2.7.5-77.el7_6.x86_64Apr 16 18:35:22 Installed: cyrus-sasl-gs2-2.1.26-21.el7.x86_64Apr 16 18:35:22 Installed: cyrus-sasl-gssapi-2.1.26-21.el7.x86_64Apr 16 18:35:22 Installed: cyrus-sasl-plain-2.1.26-21.el7.x86_64Apr 16 18:35:22 Installed: cyrus-sasl-ldap-2.1.26-21.el7.x86_64Apr 16 18:35:22 Installed: cyrus-sasl-scram-2.1.26-21.el7.x86_64Apr 16 18:35:23 Installed: net-tools-2.0-0.22.20131004git.el7.x86_64Apr 16 18:35:23 Installed: 3:mcelog-144-3.94d853b2ea81.el7.x86_64Apr 16 18:35:23 Updated: sudo-1.8.19p2-14.el7_5.x86_64Apr 16 18:35:23 Installed: crash-7.2.0-6.el7.x86_64Apr 16 18:35:23 Installed: cyrus-sasl-ntlm-2.1.26-21.el7.x86_64Apr 16 18:35:23 Installed: bc-1.06.95-13.el7.x86_64Apr 16 18:35:24 Installed: ntpdate-4.2.6p5-28.el7.centos.x86_64Apr 16 18:35:24 Installed: fping-3.10-4.el7.x86_64Apr 16 18:35:24 Installed: hdparm-9.43-5.el7.x86_64Apr 16 18:35:24 Installed: deltarpm-3.6-3.el7.x86_64Apr 16 18:35:24 Installed: iptraf-ng-1.1.4-6.el7.x86_64Apr 16 18:35:24 Installed: iperf-2.0.10-1.el7.x86_64Apr 16 18:35:24 Installed: cyrus-sasl-md5-2.1.26-21.el7.x86_64Apr 16 18:35:24 Installed: ssmtp-2.64-14.el7.x86_64Apr 16 18:35:24 Installed: 1:net-snmp-utils-5.7.2-28.el7.x86_64Apr 16 18:35:24 Updated: hwdata-0.252-9.1.el7.x86_64Apr 16 18:35:24 Installed: zookeeper-3.3.5-3.3.5-1.x86_64Apr 16 18:35:28 Installed: ntp-4.2.6p5-28.el7.centos.x86_64Apr 16 18:35:35 Updated: systemd-libs-219-42.el7_4.10.x86_64Apr 16 18:35:35 Updated: nspr-4.19.0-1.el7_5.x86_64Apr 16 18:35:35 Updated: nss-util-3.36.0-1.el7_5.x86_64Apr 16 18:35:35 Updated: libuuid-2.23.2-43.el7_4.2.x86_64Apr 16 18:35:35 Updated: 1:grub2-common-2.02-0.65.el7.centos.2.noarchApr 16 18:35:36 Updated: 1:dbus-libs-1.10.24-7.el7.x86_64Apr 16 18:35:36 Updated: 1:grub2-pc-modules-2.02-0.65.el7.centos.2.noarchApr 16 18:35:36 Updated: libstdc++-4.8.5-28.el7_5.1.x86_64Apr 16 18:35:36 Updated: kmod-libs-20-15.el7_4.4.x86_64Apr 16 18:35:36 Updated: ncurses-base-5.9-14.20130511.el7_4.noarchApr 16 18:35:36 Updated: ncurses-libs-5.9-14.20130511.el7_4.x86_64Apr 16 18:35:36 Updated: bash-4.2.46-30.el7.x86_64Apr 16 18:35:36 Installed: 1:grub2-tools-minimal-2.02-0.65.el7.centos.2.x86_64Apr 16 18:35:36 Updated: libblkid-2.23.2-43.el7_4.2.x86_64Apr 16 18:35:36 Updated: libmount-2.23.2-43.el7_4.2.x86_64Apr 16 18:35:37 Updated: glib2-2.56.1-2.el7.x86_64Apr 16 18:35:37 Updated: util-linux-2.23.2-43.el7_4.2.x86_64Apr 16 18:35:37 Updated: cpio-2.11-25.el7_4.x86_64Apr 16 18:35:38 Updated: selinux-policy-3.13.1-166.el7_4.5.noarchApr 16 18:35:38 Updated: nss-softokn-freebl-3.36.0-5.el7_5.x86_64Apr 16 18:35:38 Updated: nss-softokn-3.36.0-5.el7_5.x86_64Apr 16 18:35:38 Updated: nss-sysinit-3.36.0-5.el7_5.x86_64Apr 16 18:35:38 Updated: nss-3.36.0-5.el7_5.x86_64Apr 16 18:35:38 Updated: 1:NetworkManager-libnm-1.12.0-8.el7_6.x86_64Apr 16 18:35:38 Updated: nss-tools-3.36.0-5.el7_5.x86_64Apr 16 18:35:38 Updated: openldap-2.4.44-15.el7_5.x86_64Apr 16 18:35:39 Updated: openssh-7.4p1-16.el7.x86_64Apr 16 18:35:39 Updated: 12:dhcp-libs-4.2.5-68.el7.centos.1.x86_64Apr 16 18:35:39 Updated: 12:dhcp-common-4.2.5-68.el7.centos.1.x86_64Apr 16 18:35:39 Updated: binutils-2.25.1-32.base.el7_4.1.x86_64Apr 16 18:35:40 Updated: procps-ng-3.3.10-17.el7_5.2.x86_64Apr 16 18:35:40 Updated: dracut-033-535.el7_5.1.x86_64Apr 16 18:35:40 Updated: kmod-20-15.el7_4.4.x86_64Apr 16 18:35:41 Updated: systemd-219-42.el7_4.10.x86_64Apr 16 18:35:41 Updated: 1:dbus-1.10.24-7.el7.x86_64Apr 16 18:35:41 Installed: 1:grub2-tools-2.02-0.65.el7.centos.2.x86_64Apr 16 18:35:42 Installed: 1:grub2-tools-extra-2.02-0.65.el7.centos.2.x86_64Apr 16 18:35:42 Updated: 1:grub2-pc-2.02-0.65.el7.centos.2.x86_64Apr 16 18:35:42 Updated: polkit-0.112-18.el7_6.1.x86_64Apr 16 18:35:42 Updated: systemd-sysv-219-42.el7_4.10.x86_64Apr 16 18:35:42 Updated: 1:wpa_supplicant-2.6-5.el7_4.1.x86_64Apr 16 18:35:43 Updated: 1:NetworkManager-1.12.0-8.el7_6.x86_64Apr 16 18:35:43 Updated: 32:bind-license-9.9.4-74.el7_6.1.noarchApr 16 18:35:43 Updated: 32:bind-libs-lite-9.9.4-74.el7_6.1.x86_64Apr 16 18:35:43 Updated: 12:dhclient-4.2.5-68.el7.centos.1.x86_64Apr 16 18:35:43 Updated: dracut-network-033-535.el7_5.1.x86_64Apr 16 18:35:43 Updated: kexec-tools-2.0.15-13.el7_5.2.x86_64Apr 16 18:35:43 Updated: 1:NetworkManager-wifi-1.12.0-8.el7_6.x86_64Apr 16 18:35:43 Updated: 1:NetworkManager-tui-1.12.0-8.el7_6.x86_64Apr 16 18:35:43 Updated: 1:NetworkManager-team-1.12.0-8.el7_6.x86_64Apr 16 18:35:43 Installed: 1:grub2-2.02-0.65.el7.centos.2.x86_64Apr 16 18:35:43 Updated: openssh-server-7.4p1-16.el7.x86_64Apr 16 18:35:43 Updated: 2:microcode_ctl-2.1-22.el7.x86_64Apr 16 18:35:43 Updated: dracut-config-rescue-033-535.el7_5.1.x86_64Apr 16 18:35:43 Updated: openssh-clients-7.4p1-16.el7.x86_64Apr 16 18:35:44 Updated: gnupg2-2.0.22-5.el7_5.x86_64Apr 16 18:35:52 Updated: selinux-policy-targeted-3.13.1-166.el7_4.5.noarchApr 16 18:35:52 Updated: ncurses-5.9-14.20130511.el7_4.x86_64Apr 16 18:35:52 Updated: tzdata-2017c-1.el7.noarchApr 16 18:35:52 Updated: yum-plugin-fastestmirror-1.1.31-46.el7_5.noarchApr 16 18:35:52 Updated: libssh2-1.4.3-12.el7_6.2.x86_64Apr 16 18:37:00 Installed: 1:mariadb-devel-5.5.60-1.el7_5.x86_64Apr 16 18:37:01 Installed: protobuf-2.4.1-1.x86_64Apr 16 18:37:01 Installed: protobuf-python-2.5.0-8.el7.x86_64Apr 16 18:37:04 Installed: umonitor3-agent-2.2.4-1.x86_64Apr 16 18:37:10 Installed: omega_sentinel-3.3.6-1.x86_64Apr 16 18:37:27 Installed: ucloud-secagent-1.0.29-1.x86_64Apr 16 18:37:28 Installed: filebeat-6.2.4-1.x86_64Apr 16 18:37:30 Installed: oniguruma-5.9.5-3.el7.x86_64Apr 16 18:37:30 Installed: jq-1.5-1.el7.x86_64Apr 16 18:37:33 Installed: mailx-12.5-16.el7.x86_64Apr 16 18:37:33 Installed: 1:smartmontools-7.0-1.el7.ucloud.x86_64Apr 16 18:37:34 Installed: lldpd-1.0.3-1.1.x86_64Apr 16 18:37:34 Installed: ssaducli-2.65-7.0.x86_64Apr 16 18:37:35 Installed: Arcconf-3.02-23597.x86_64Apr 16 18:37:35 Installed: perccli-1.17.10-1.noarchApr 16 18:37:36 Installed: ssacli-3.25-4.0.x86_64Apr 16 18:37:36 Installed: nvme-cli-1.6-1.el7.x86_64Apr 20 16:40:35 Erased: 1:java-1.6.0-openjdk-1.6.0.41-1.13.13.1.el7_3.x86_64Apr 20 16:40:35 Erased: firewalld-0.4.4.4-6.el7.noarchApr 20 16:40:35 Erased: pulseaudio-libs-10.0-3.el7.x86_64Apr 20 16:40:36 Erased: libsndfile-1.0.25-10.el7.x86_64Apr 20 16:40:36 Erased: libXtst-1.2.3-1.el7.x86_64Apr 20 16:40:36 Erased: giflib-4.1.6-9.el7.x86_64Apr 20 16:40:36 Erased: alsa-firmware-1.0.28-2.el7.noarchApr 20 16:40:36 Erased: alsa-tools-firmware-1.1.0-1.el7.x86_64Apr 20 16:40:36 Erased: python-firewall-0.4.4.4-6.el7.noarchApr 20 16:40:36 Erased: python-slip-dbus-0.4.0-2.el7.noarchApr 20 16:40:36 Erased: python-slip-0.4.0-2.el7.noarchApr 20 16:40:36 Erased: javapackages-tools-3.4.1-11.el7.noarchApr 20 16:40:36 Erased: libXi-1.7.9-1.el7.x86_64Apr 20 16:40:36 Erased: fontconfig-2.13.0-4.3.el7.x86_64Apr 20 16:40:36 Erased: dejavu-sans-fonts-2.33-6.el7.noarchApr 20 16:40:36 Erased: dejavu-fonts-common-2.33-6.el7.noarchApr 20 16:40:36 Erased: python-javapackages-3.4.1-11.el7.noarchApr 20 16:40:36 Erased: libXext-1.3.3-3.el7.x86_64Apr 20 16:40:36 Erased: libSM-1.2.2-2.el7.x86_64Apr 20 16:40:36 Erased: flac-libs-1.3.0-5.el7_1.x86_64Apr 20 16:40:37 Erased: 1:libvorbis-1.3.3-8.el7.x86_64Apr 20 16:40:37 Erased: ipset-6.29-1.el7.x86_64Apr 20 16:40:37 Erased: libXcomposite-0.4.4-4.1.el7.x86_64Apr 20 16:40:37 Erased: libXrender-0.9.10-1.el7.x86_64Apr 20 16:40:37 Erased: libX11-1.6.5-1.el7.x86_64Apr 20 16:40:37 Erased: libxcb-1.12-1.el7.x86_64Apr 20 16:40:37 Erased: kexec-tools-2.0.15-13.el7_5.2.x86_64Apr 20 16:40:37 Erased: dracut-network-033-535.el7_5.1.x86_64Apr 20 16:40:37 Erased: 12:dhclient-4.2.5-68.el7.centos.1.x86_64Apr 20 16:40:37 Erased: 12:dhcp-common-4.2.5-68.el7.centos.1.x86_64Apr 20 16:40:37 Erased: 12:dhcp-libs-4.2.5-68.el7.centos.1.x86_64Apr 20 16:40:37 Erased: libX11-common-1.6.5-1.el7.noarchApr 20 16:40:37 Erased: fontpackages-filesystem-1.44-8.el7.noarchApr 20 16:40:37 Erased: firewalld-filesystem-0.4.4.4-6.el7.noarchApr 20 16:40:37 Erased: mailcap-2.1.41-2.el7.noarchApr 20 16:40:38 Erased: tzdata-java-2017c-1.el7.noarchApr 20 16:40:38 Erased: 32:bind-libs-lite-9.9.4-74.el7_6.1.x86_64Apr 20 16:40:38 Erased: 32:bind-license-9.9.4-74.el7_6.1.noarchApr 20 16:40:38 Erased: GeoIP-1.5.0-11.el7.x86_64Apr 20 16:40:38 Erased: libXau-1.0.8-2.1.el7.x86_64Apr 20 16:40:38 Erased: ipset-libs-6.29-1.el7.x86_64Apr 20 16:40:38 Erased: 2:libogg-1.3.0-7.el7.x86_64Apr 20 16:40:38 Erased: libICE-1.0.9-9.el7.x86_64Apr 20 16:40:38 Erased: python-lxml-3.2.1-4.el7.x86_64Apr 20 16:40:38 Erased: libselinux-python-2.5-11.el7.x86_64Apr 20 16:40:38 Erased: fxload-2002_04_11-16.el7.x86_64Apr 20 16:40:38 Erased: alsa-lib-1.1.3-3.el7.x86_64Apr 20 16:40:38 Erased: gsm-1.0.13-11.el7.x86_64Apr 20 16:40:38 Erased: libasyncns-0.8-7.el7.x86_64Apr 20 16:40:39 Erased: ebtables-2.0.10-15.el7.x86_64Apr 20 16:40:39 Erased: libjpeg-turbo-1.2.90-5.el7.x86_64Apr 20 16:40:39 Erased: 3:irqbalance-1.0.7-10.el7.x86_64Apr 20 16:40:46 Installed: 7:device-mapper-event-libs-1.02.140-8.el7.x86_64Apr 20 16:40:47 Installed: GeoIP-1.5.0-11.el7.x86_64Apr 20 16:40:47 Installed: 7:device-mapper-event-1.02.140-8.el7.x86_64Apr 20 16:40:47 Installed: 7:lvm2-libs-2.02.171-8.el7.x86_64Apr 20 16:40:47 Installed: 32:bind-license-9.9.4-74.el7_6.1.noarchApr 20 16:40:47 Installed: 32:bind-libs-9.9.4-74.el7_6.1.x86_64Apr 20 16:40:47 Installed: device-mapper-persistent-data-0.7.0-0.1.rc6.el7.x86_64Apr 20 16:40:47 Installed: libnetfilter_cthelper-1.0.0-9.el7.x86_64Apr 20 16:40:48 Installed: libnetfilter_queue-1.0.2-2.el7_2.x86_64Apr 20 16:40:48 Installed: libnetfilter_cttimeout-1.0.0-6.el7.x86_64Apr 20 16:40:48 Installed: conntrack-tools-1.4.4-3.el7_3.x86_64Apr 20 16:40:49 Installed: 7:lvm2-2.02.171-8.el7.x86_64Apr 20 16:40:49 Installed: 32:bind-utils-9.9.4-74.el7_6.1.x86_64Apr 20 16:40:49 Installed: socat-1.7.3.2-2.el7.x86_64Apr 20 16:40:49 Installed: tree-1.6.0-10.el7.x86_64Apr 20 16:40:49 Installed: ipvsadm-1.27-7.el7.x86_64Apr 20 16:40:49 Installed: 1:telnet-0.17-64.el7.x86_64Apr 20 16:40:56 Installed: 12:dhcp-libs-4.2.5-68.el7.centos.1.x86_64Apr 20 16:40:56 Installed: 12:dhcp-common-4.2.5-68.el7.centos.1.x86_64Apr 20 16:40:56 Installed: 32:bind-libs-lite-9.9.4-74.el7_6.1.x86_64Apr 20 16:40:56 Installed: 12:dhclient-4.2.5-68.el7.centos.1.x86_64Apr 20 16:40:56 Installed: dracut-network-033-535.el7_5.1.x86_64Apr 20 16:40:57 Installed: kexec-tools-2.0.15-13.el7_5.2.x86_64Apr 20 16:41:36 Erased: kexec-tools-2.0.15-13.el7_5.2.x86_64Apr 20 16:41:36 Erased: dracut-network-033-535.el7_5.1.x86_64Apr 20 16:41:36 Erased: 12:dhclient-4.2.5-68.el7.centos.1.x86_64Apr 20 16:41:36 Erased: 12:dhcp-common-4.2.5-68.el7.centos.1.x86_64Apr 20 16:41:36 Erased: 12:dhcp-libs-4.2.5-68.el7.centos.1.x86_64Apr 20 16:41:36 Erased: 32:bind-libs-lite-9.9.4-74.el7_6.1.x86_64Apr 20 16:41:43 Installed: 12:dhcp-libs-4.2.5-68.el7.centos.1.x86_64Apr 20 16:41:43 Installed: 12:dhcp-common-4.2.5-68.el7.centos.1.x86_64Apr 20 16:41:44 Installed: 32:bind-libs-lite-9.9.4-74.el7_6.1.x86_64Apr 20 16:41:44 Installed: 12:dhclient-4.2.5-68.el7.centos.1.x86_64Apr 20 16:41:44 Installed: dracut-network-033-535.el7_5.1.x86_64Apr 20 16:41:44 Installed: kexec-tools-2.0.15-13.el7_5.2.x86_64Apr 20 16:42:52 Installed: ipset-libs-6.29-1.el7.x86_64Apr 20 16:42:52 Installed: keepalived-1.3.5-8.el7_6.x86_64Apr 20 19:06:39 Installed: 2:nmap-ncat-6.40-7.el7.x86_64Apr 20 19:06:39 Installed: rsync-3.0.9-17.el7.x86_64Apr 20 19:07:04 Updated: rsync-3.0.9-18.el7.x86_64Apr 20 19:19:12 Installed: patch-2.7.1-10.el7_5.x86_64Apr 20 20:36:57 Installed: unbound-1.4.20-34.el7.x86_64Apr 20 20:36:57 Installed: openvswitch-2.10.5-2.el7.centos.x86_64Apr 21 09:46:32 Installed: rdma-core-13-7.el7.x86_64Apr 21 09:46:32 Installed: libibverbs-13-7.el7.x86_64Apr 21 09:46:32 Installed: librdmacm-13-7.el7.x86_64Apr 21 16:20:53 Installed: setools-libs-3.3.8-1.1.el7.x86_64Apr 21 16:20:53 Installed: checkpolicy-2.5-4.el7.x86_64Apr 21 16:20:53 Installed: libseccomp-2.3.1-3.el7.x86_64Apr 21 16:20:53 Installed: libselinux-python-2.5-11.el7.x86_64Apr 21 16:20:53 Installed: audit-libs-python-2.7.6-3.el7.x86_64Apr 21 16:20:53 Installed: python-IPy-0.75-6.el7.noarchApr 21 16:20:53 Installed: libsemanage-python-2.5-8.el7.x86_64Apr 21 16:20:53 Installed: policycoreutils-python-2.5-17.1.el7.x86_64Apr 21 16:21:15 Installed: 2:container-selinux-2.28-1.git85ce147.el7.noarchApr 21 16:21:17 Installed: docker-engine-1.12.6-10.el7.ucloud.x86_64Apr 22 15:05:25 Installed: lz4-1.7.5-3.el7.x86_64Apr 22 15:05:25 Updated: systemd-libs-219-67.el7_7.4.x86_64Apr 22 15:05:25 Installed: json-c-0.11-4.el7_0.x86_64Apr 22 15:05:25 Updated: cryptsetup-libs-2.0.3-5.el7.x86_64Apr 22 15:05:27 Updated: systemd-219-67.el7_7.4.x86_64Apr 22 15:05:27 Updated: systemd-sysv-219-67.el7_7.4.x86_64Apr 26 15:01:07 Installed: 1:perl-Error-0.17020-2.el7.noarchApr 26 15:01:08 Installed: perl-TermReadKey-2.30-20.el7.x86_64Apr 26 15:01:09 Installed: git-1.8.3.1-20.el7.x86_64Apr 26 15:01:09 Installed: perl-Git-1.8.3.1-20.el7.noarchApr 27 14:20:30 Installed: lrzsz-0.12.20-36.el7.x86_64Apr 27 14:27:46 Installed: unzip-6.0-16.el7.x86_64Apr 27 14:52:27 Installed: dos2unix-6.0.3-7.el7.x86_64Apr 28 17:56:52 Erased: kexec-tools-2.0.15-13.el7_5.2.x86_64Apr 28 17:56:52 Erased: dracut-network-033-535.el7_5.1.x86_64Apr 28 17:56:52 Erased: 12:dhclient-4.2.5-68.el7.centos.1.x86_64Apr 28 17:56:52 Erased: 12:dhcp-common-4.2.5-68.el7.centos.1.x86_64Apr 28 17:56:52 Erased: 12:dhcp-libs-4.2.5-68.el7.centos.1.x86_64Apr 28 17:56:52 Erased: 32:bind-libs-lite-9.9.4-74.el7_6.1.x86_64Apr 29 15:41:38 Installed: gdb-7.6.1-100.el7.x86_64Apr 29 19:13:33 Installed: nethogs-0.8.5-1.el7.x86_64May 18 21:24:35 Installed: libref_array-0.1.5-27.el7.x86_64May 18 21:24:35 Installed: libcollection-0.6.2-27.el7.x86_64May 18 21:24:35 Installed: libbasicobjects-0.1.1-27.el7.x86_64May 18 21:24:35 Installed: libtirpc-0.2.4-0.10.el7.x86_64May 18 21:24:36 Installed: rpcbind-0.2.0-42.el7.x86_64May 18 21:24:36 Installed: 1:quota-nls-4.01-14.el7.noarchMay 18 21:24:36 Installed: libpath_utils-0.2.1-27.el7.x86_64May 18 21:24:36 Installed: libini_config-1.3.0-27.el7.x86_64May 18 21:24:36 Installed: tcp_wrappers-7.6-77.el7.x86_64May 18 21:24:36 Installed: 1:quota-4.01-14.el7.x86_64May 18 21:24:37 Installed: libverto-libevent-0.2.5-4.el7.x86_64May 18 21:24:37 Installed: gssproxy-0.7.0-4.el7.x86_64May 18 21:24:37 Installed: keyutils-1.5.8-3.el7.x86_64May 18 21:24:37 Installed: libnfsidmap-0.25-17.el7.x86_64May 18 21:24:38 Installed: 1:nfs-utils-1.3.0-0.48.el7_4.x86_64Jun 08 16:01:26 Updated: umonitor3-agent-2.2.6-1.x86_64Jun 09 18:18:37 Installed: strace-4.12-4.el7.x86_64Jun 10 11:07:59 Installed: time-1.7-45.el7.x86_64Jun 10 16:01:10 Updated: omega_sentinel-3.3.11-1.x86_64Jun 10 17:43:35 Installed: boost-system-1.53.0-27.el7.x86_64Jun 10 17:43:35 Installed: boost-chrono-1.53.0-27.el7.x86_64Jun 10 17:43:35 Installed: boost-thread-1.53.0-27.el7.x86_64Jun 10 17:43:36 Installed: libicu-50.1.2-15.el7.x86_64Jun 10 17:43:36 Installed: boost-regex-1.53.0-27.el7.x86_64Jun 10 17:43:37 Installed: boost-filesystem-1.53.0-27.el7.x86_64Jun 10 17:43:37 Installed: boost-date-time-1.53.0-27.el7.x86_64Jun 10 17:43:37 Installed: boost-wave-1.53.0-27.el7.x86_64Jun 10 17:43:37 Installed: boost-graph-1.53.0-27.el7.x86_64Jun 10 17:43:37 Installed: boost-locale-1.53.0-27.el7.x86_64Jun 10 17:43:37 Installed: boost-timer-1.53.0-27.el7.x86_64Jun 10 17:43:37 Installed: boost-python-1.53.0-27.el7.x86_64Jun 10 17:43:38 Installed: boost-atomic-1.53.0-27.el7.x86_64Jun 10 17:43:38 Installed: boost-math-1.53.0-27.el7.x86_64Jun 10 17:43:38 Installed: boost-signals-1.53.0-27.el7.x86_64Jun 10 17:43:38 Installed: boost-context-1.53.0-27.el7.x86_64Jun 10 17:43:38 Installed: boost-iostreams-1.53.0-27.el7.x86_64Jun 10 17:43:38 Installed: boost-program-options-1.53.0-27.el7.x86_64Jun 10 17:43:38 Installed: boost-random-1.53.0-27.el7.x86_64Jun 10 17:43:39 Installed: boost-test-1.53.0-27.el7.x86_64Jun 10 17:43:39 Installed: boost-serialization-1.53.0-27.el7.x86_64Jun 10 17:43:39 Installed: boost-1.53.0-27.el7.x86_64Jun 14 20:34:51 Installed: freeipmi-1.2.9-8.el7.x86_64Jun 14 20:34:51 Installed: yajl-2.0.4-4.el7.x86_64Jun 14 20:34:51 Updated: ipmitool-1.8.18-9.el7_7.x86_64Jun 14 20:34:51 Installed: libtool-ltdl-2.4.2-22.el7_3.x86_64Jun 14 20:34:52 Installed: collectd-5.7.1-2.el7.x86_64Jun 14 20:34:52 Installed: ncurses-devel-5.9-14.20130511.el7_4.x86_64Jun 14 20:34:52 Installed: pexpect-2.3-11.el7.noarchJun 14 20:34:56 Installed: fence-agents-common-4.0.11-66.el7_4.3.x86_64Jun 14 20:34:56 Installed: fence-agents-ipmilan-4.0.11-66.el7_4.3.x86_64Jun 14 20:34:56 Installed: OpenIPMI-devel-2.0.19-15.el7.x86_64Jun 14 20:34:56 Installed: collectd-ipmi-5.7.1-2.el7.x86_64Jun 14 20:34:56 Installed: freeipmi-bmc-watchdog-1.2.9-8.el7.x86_64Jun 14 20:34:57 Installed: freeipmi-ipmiseld-1.2.9-8.el7.x86_64Jun 14 20:34:57 Installed: freeipmi-devel-1.2.9-8.el7.x86_64Jun 14 20:34:57 Installed: freeipmi-ipmidetectd-1.2.9-8.el7.x86_64Jun 14 20:34:57 Installed: ipmiutil-devel-3.0.1-1.el7.x86_64Jun 14 20:34:57 Installed: ipmiutil-debuginfo-3.0.1-1.el7.x86_64Jun 14 20:34:57 Installed: OpenIPMI-python-2.0.19-15.el7.x86_64Jun 14 20:35:13 Installed: ipmiutil-3.0.1-1.el7.x86_64Jun 14 20:35:13 Installed: ipmiutil-static-3.0.1-1.el7.x86_64Jun 14 20:35:13 Installed: OpenIPMI-perl-2.0.19-15.el7.x86_64Jun 24 14:02:49 Installed: 2:nmap-6.40-7.el7.x86_64Jun 24 14:03:21 Erased: 2:nmap-6.40-7.el7.x86_64
"

type Case struct {
ts int64
str string
cut bool
}

func TestLargeBlock(t *testing.T) {
enc := EncGZIP

t.Run(enc.String(), func(t *testing.T) {
	chk := NewMemChunk(enc, testBlockSize, testTargetSize)
	var cases []Case

	for i := 0; i <= 25; i++ {
		cases = append(cases, Case{
			ts:  int64(i),
			str: line,
		})
	}

	for _, c := range cases {
		require.NoError(t, chk.Append(logprotoEntry(c.ts, c.str)))
		if c.cut {
			require.NoError(t, chk.cut())
		}
	}

	it, err := chk.Iterator(context.Background(), time.Unix(0, 0), time.Unix(0, math.MaxInt64), logproto.FORWARD, nil)
	require.NoError(t, err)

	idx := 0
	for it.Next() {
		e := it.Entry()
		require.Equal(t, cases[idx].ts, e.Timestamp.UnixNano())
		require.Equal(t, cases[idx].str, e.Line)
		idx++
	}

	require.NoError(t, it.Error())
	require.Equal(t, len(cases), idx)

	t.Run("bounded-iteration", func(t *testing.T) {
		it, err := chk.Iterator(context.Background(), time.Unix(0, 3), time.Unix(0, 7), logproto.FORWARD, nil)
		require.NoError(t, err)

		idx := 2
		for it.Next() {
			e := it.Entry()
			require.Equal(t, cases[idx].ts, e.Timestamp.UnixNano())
			require.Equal(t, cases[idx].str, e.Line)
			idx++
		}
		require.NoError(t, it.Error())
		require.Equal(t, 6, idx)
	})
})

}

`

I don't know what to do next, I was wondering if you have any suggestion.

@quchenyuan
Copy link
Author

Okay, I found where the bug is, in ./loki/pkg/chunkenc/memchunk.go,

`// moveNext moves the buffer to the next entry
func (si *bufferedIterator) moveNext() (int64, []byte, bool) {
...

// Then process reading the line.
n, err := si.bufReader.Read(si.buf[:lineSize])
if err != nil && err != io.EOF {
	si.err = err
	return 0, nil, false
}
for n < lineSize {
	r, err := si.bufReader.Read(si.buf[n:lineSize])
	if err != nil {    //  this line 
		si.err = err
		return 0, nil, false
	}
	n += r
}
return ts, si.buf[:lineSize], true

}
`

In the for loop, should change the if clause to if err != nil && err != io.EOF,or else we'll miss the last log entry of a block.

@cyriltovena
Copy link
Contributor

Nice found ! I think you’re right, you’re unlucky cause this code triggers with only very long line. I’ll try to fix it today.

@cyriltovena cyriltovena self-assigned this Jul 7, 2020
@cyriltovena cyriltovena added keepalive An issue or PR that will be kept alive and never marked as stale. kind/bug component/loki labels Jul 7, 2020
cyriltovena added a commit to cyriltovena/loki that referenced this issue Jul 7, 2020
Funny enough this was triggered only with gzip and only with a certain size. But thanks for investigation here grafana#2272 I was able to reproduce this with a test and indeed this was incorrect.

Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
@quchenyuan
Copy link
Author

Interesting. I digged a little into it, and found that gzip's readHeader function may return io.EOF. Here's the comment in the source code:
// RFC 1952, section 2.2, says the following:
// A gzip file consists of a series of "members" (compressed data sets).
//
// Other than this, the specification does not clarify whether a
// "series" is defined as "one or more" or "zero or more". To err on the
// side of caution, Go interprets this to mean "zero or more".
// Thus, it is okay to return io.EOF here.

owen-d pushed a commit that referenced this issue Jul 8, 2020
Funny enough this was triggered only with gzip and only with a certain size. But thanks for investigation here #2272 I was able to reproduce this with a test and indeed this was incorrect.

Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
@cyriltovena
Copy link
Contributor

Yes I was able to reproduce only with GZIP and not always. Anyway that's seems to be fixed now.

Btw @quchenyuan if you have a lot of logs and Loki is not performing as fast as you want you can switch to snappy. You'll trade a bit of compression ratio but at least it will be way faster. Depends on your use case though gzip is 10x compression ratio and snappy is 5x.

@quchenyuan
Copy link
Author

@cyriltovena Thanks! This looks great to me.

@chaudum chaudum added the type/bug Somehing is not working as expected label Jun 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/loki keepalive An issue or PR that will be kept alive and never marked as stale. type/bug Somehing is not working as expected
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants