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

panic: runtime error: index out of range #3

Open
plessbd opened this issue Jun 4, 2019 · 6 comments
Open

panic: runtime error: index out of range #3

plessbd opened this issue Jun 4, 2019 · 6 comments

Comments

@plessbd
Copy link

plessbd commented Jun 4, 2019

./dw-query-digest-amd64 -debug /data/database/db-slow.log
INFO[0000] using "/data/database/db-slow.log" as input file
INFO[0000] using "terminal" output
ERRO[0000] cachefile /data/database/db-slow.log not found: stat /data/database/db-slow.log.cache: no such file or directory
INFO[0000] file has 5933 lines
ERRO[0000] error reading log header: unable to parse server information; beginning of log might be missing
DEBU[0000] line (7) will fold after SELECT
DEBU[0000] line (8) will fold after
DEBU[0000] line (9) will fold after
DEBU[0000] line (10) will fold after
DEBU[0000] line (11) will fold after
DEBU[0000] line (12) will fold after
DEBU[0000] worker exiting
panic: runtime error: index out of range

goroutine 6 [running]:
main.fileReader(0xc000019cf0, 0x5aa9a0, 0xc00000e0a0, 0xc0000569c0, 0x172d)
	/home/leucos/dev/perso/projects/dw-query-digest/main.go:456 +0xaa0
created by main.main
	/home/leucos/dev/perso/projects/dw-query-digest/main.go:303 +0xafa
[root@db ~]# head -n15 /data/database/db-slow.log
/usr/libexec/mysqld, Version: 5.5.60-MariaDB (MariaDB Server). started with:
Tcp port: 3306  Unix socket: /var/lib/mysql/mysql.sock
Time                 Id Command    Argument
# Time: 190603 23:14:02
# User@Host: user[user] @  [172.22.0.10]
# Thread_id: 3  Schema: thedb  QC_hit: No
# Query_time: 0.167214  Lock_time: 0.166911  Rows_sent: 1  Rows_examined: 69
use thedb;
SET timestamp=1559618042;
SELECT
                id, password
            FROM
                Users
            WHERE
                username = 'olntwrdorwvtor'
                AND user_type != '14';
# User@Host: user[user] @  [172.22.0.10]
@leucos
Copy link
Contributor

leucos commented Jun 4, 2019

Thanks for the bug report @plessbd .

I can reproduce the header parsing problem using your log file, but not the crash. Are you using v0.8 ?

/usr/libexec/mysqld, Version: 5.5.60-MariaDB (MariaDB Server). started with:
Tcp port: 3306  Unix socket: /var/lib/mysql/mysql.sock
Time                 Id Command    Argument
# Time: 190603 23:14:02
# User@Host: user[user] @  [172.22.0.10]
# Thread_id: 3  Schema: thedb  QC_hit: No
# Query_time: 0.167214  Lock_time: 0.166911  Rows_sent: 1  Rows_examined: 69
use thedb;
SET timestamp=1559618042;
SELECT
                id, password
            FROM
                Users
            WHERE
                username = 'olntwrdorwvtor'
                AND user_type != '14';
# User@Host: user[user] @  [172.22.0.10]
$ md5sum issue.log
144906c84b46036d3744096dbb88c7af  issue.log

leucos added a commit that referenced this issue Jun 4, 2019
Fixed header so upper case can be matched in server version names.
Fixes part of #3
@leucos
Copy link
Contributor

leucos commented Jun 4, 2019

@plessbd I've pushed a fix on master that should take care of MariaDB server version parsing.
Can you build master and try again ? If it is a burden, don't hesitate asking and I'll release a binary.

Thanks !

@plessbd
Copy link
Author

plessbd commented Jun 4, 2019

The ERRO[0000] error reading log header: unable to parse server information; beginning of log might be missing is resolved

so that was a truncated log and I assumed the issue was with lines 7 - 12 of the querylog.

Could it be in a different query that the error is happening?

root@220e9245c0cc:/go/dw-query-digest# md5sum /scratch/scratch/issue.log
9709cc10feee84459188e9ef869c84c7  /scratch/scratch/issue.log
root@220e9245c0cc:/go/dw-query-digest# cat /scratch/scratch/issue.log
/usr/libexec/mysqld, Version: 5.5.60-MariaDB (MariaDB Server). started with:
Tcp port: 3306  Unix socket: /var/lib/mysql/mysql.sock
Time                 Id Command    Argument
# Time: 190603 23:14:02
# User@Host: user[user] @  [172.22.0.10]
# Thread_id: 3  Schema: thedb  QC_hit: No
# Query_time: 0.167214  Lock_time: 0.166911  Rows_sent: 1  Rows_examined: 69
use thedb;
SET timestamp=1559618042;
SELECT
                id, password
            FROM
                Users
            WHERE
                username = 'olntwrdorwvtor'
                AND user_type != '14';
# User@Host: user[user] @  [172.22.0.10]
# Thread_id: 3  Schema: thedb  QC_hit: No
# Query_time: 0.000089  Lock_time: 0.000020  Rows_sent: 0  Rows_examined: 69
SET timestamp=1559618042;
SELECT id FROM Users WHERE username=NULL;

@leucos
Copy link
Contributor

leucos commented Jun 4, 2019

@plessbd I reproduced:

9709cc10feee84459188e9ef869c84c7  issue.log
$ ./bin/dw-query-digest --nocache --debug issue.log
INFO[0000] using "issue.log" as input file              
INFO[0000] using "terminal" output                      
INFO[0000] file has 21 lines                            
INFO[0000] aggregator started                           
DEBU[0000] line (7) will fold after SELECT              
DEBU[0000] line (8) will fold after                     
DEBU[0000] line (9) will fold after                     
DEBU[0000] line (10) will fold after                    
DEBU[0000] line (11) will fold after                    
DEBU[0000] line (12) will fold after                    
DEBU[0000] worker exiting                               
panic: runtime error: index out of range

goroutine 6 [running]:
main.fileReader(0xc00001ddb0, 0x5abce0, 0xc0000100a0, 0xc0000a48a0, 0x15)
	/home/leucos/dev/perso/projects/dw-query-digest/main.go:456 +0xaa0
created by main.main
	/home/leucos/dev/perso/projects/dw-query-digest/main.go:303 +0xafa

I'll look into it.
Thanks !

@leucos leucos closed this as completed in 54196e2 Jun 5, 2019
@leucos
Copy link
Contributor

leucos commented Jun 5, 2019

Hey @plessbd . It should be fixed now. If you can give it a try, I'll release afterwards. Thanks !

@leucos leucos reopened this Jun 5, 2019
@plessbd
Copy link
Author

plessbd commented Jun 6, 2019

It seems to work. However I do get A LOT of warnings about
WARN[0027] request to add element 8 for line "some sql" exceeds capacity for what seems like every line
it seems your change on

if curline < cap(curentry.lines)-1 {
of adding the -1 is causing the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants