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

Bug: write fields error 0: conn 0: Check conn status error #317

Closed
dongzl opened this issue Jul 27, 2022 · 2 comments · Fixed by #328
Closed

Bug: write fields error 0: conn 0: Check conn status error #317

dongzl opened this issue Jul 27, 2022 · 2 comments · Fixed by #328
Assignees
Labels
bug Something isn't working

Comments

@dongzl
Copy link
Contributor

dongzl commented Jul 27, 2022

What happened:

What you expected to happen:

How to reproduce it (as minimally and precisely as possible):

Anything else we need to know?:

  • use mysql client connect arana, execute SQL is OK.

  • use follow code insert data:

package mysql

import (
	"database/sql"
	"fmt"
	_ "github.com/go-sql-driver/mysql"
	"testing"
	"time"
)

func Test_sequence(t *testing.T) {
	// DSN:Data Source Name
	dsn := "dksl:123456@tcp(127.0.0.1:13306)/employees"
	db, err := sql.Open("mysql", dsn)
	if err != nil {
		panic(err)
	}
	defer db.Close() // 注意这行代码要写在上面err判断的下面

	start := time.Now().Unix()
	sqlStr := "INSERT INTO student (uid, name, score, nickname, gender, birth_year, created_at, modified_at) VALUES (?, ?, 95, ?, 0, 16, NOW(), NOW());"
	for i := 0; i < 1000; i++ {
		ret, err := db.Exec(sqlStr, i, fmt.Sprintf("%s_%d", "scott", i), fmt.Sprintf("%s_%d", "nc_scott", i))
		if err != nil {
			fmt.Printf("insert failed, err:%v\n", err)
			return
		}
		theID, err := ret.LastInsertId() // 新插入数据的id
		if err != nil {
			fmt.Printf("get lastinsert ID failed, err:%v\n", err)
			return
		}
		fmt.Printf("insert success, the id is %d.\n", theID)
	}
	fmt.Println(time.Now().Unix() - start)
}
  • use mysql client connect arana, execute is error.

image

  • arana console error msg:
2022-07-27T11:57:48.328+0800    ERROR   mysql/execute_handle.go:122     write fields error 0: conn 0: Check conn status error
github.com/arana-db/arana/pkg/mysql.(*Listener).handleQuery
        /Users/dongzonglei/source_code/Github/arana/pkg/mysql/execute_handle.go:122
github.com/arana-db/arana/pkg/mysql.(*Listener).ExecuteCommand
        /Users/dongzonglei/source_code/Github/arana/pkg/mysql/server.go:553
github.com/arana-db/arana/pkg/mysql.(*Listener).handle
        /Users/dongzonglei/source_code/Github/arana/pkg/mysql/server.go:203
2022-07-27T11:57:48.328+0800    ERROR   mysql/server.go:207     failed to execute command: conn 0: Check conn status error
github.com/arana-db/arana/pkg/mysql.(*Listener).handle
        /Users/dongzonglei/source_code/Github/arana/pkg/mysql/server.go:207
2022-07-27T11:57:49.949+0800    DEBUG   executor/redirect.go:172        ComQuery: show databases
2022-07-27T11:57:49.949+0800    DEBUG   executor/redirect.go:172        ComQuery: show tables
@dongzl dongzl added the bug Something isn't working label Jul 27, 2022
@Penglq
Copy link
Contributor

Penglq commented Jul 28, 2022

image
the connection#5 of remote client 127.0.0.1:55199 requests quit

image

image

@Penglq
Copy link
Contributor

Penglq commented Jul 28, 2022

This problem occurs when the mysql client queries again after the GO client executes the statement and exits

Penglq added a commit to Penglq/arana that referenced this issue Jul 30, 2022
binbin0325 pushed a commit to binbin0325/arana that referenced this issue Jul 31, 2022
* Add: add test case for iterator.

* fix: format import.

* fix: fix test case error.

* Add: add test case for shard_expr.

* Add: add license header.

* Add: add new test case.

* fix: fix import format.

* refactor schemanager cache to lru cache (arana-db#246)

Co-authored-by: Dong Jianhui <dongjianhui03@meituan.com>

* optimize maxAllowedPacket config fix: arana-db#292 arana-db#281 (arana-db#297)

* insert multi value at once request, throw error msg when any row error fix: arana-db#287 (arana-db#313)

* feat: support show status (arana-db#309)

* feat: max_allowed_packet is set by the user (arana-db#312)

Co-authored-by: Zonglei Dong <dongzonglei@apache.org>
Co-authored-by: Mulavar <978007503@qq.com>
Co-authored-by: Dong Jianhui <dongjianhui03@meituan.com>
Co-authored-by: adair peng <luqiangpeng5945@gmail.com>

* style: fix code style

* ci: fix ci bug

* ci: fix ci bug

* ci: fix ci error

* fix: fix ci bug

* fix: fix runtime.Runtime use

Co-authored-by: Jeffsky <jjeffcaii@outlook.com>
Co-authored-by: Zonglei Dong <dongzonglei@apache.org>
Co-authored-by: Mulavar <978007503@qq.com>
Co-authored-by: Dong Jianhui <dongjianhui03@meituan.com>
Co-authored-by: adair peng <luqiangpeng5945@gmail.com>

debug: listen capabilities fix:arana-db#317 (arana-db#328)

feat: support "show collation" SQL statement. (arana-db#307)

chore: add unit test. (arana-db#323)

* Add: add unit test for api.go.

* Add: add license header.

* fix: fix import format.

* fix: refactor mock file directory.

* fix: fix import format.

* fix: fix path name.

* fix: fix test config file content.

* add: add test case for file.go .

* fix: fix import format.

* fix: fix file format.

* fix: fix code review problem.

* fix: fix error test case.

* fix: fix bootstrap test config.

* fix: fix test config data.

commit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants