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

Excuse me, how can I debug "unexpected read from socket" if it occurs? #3

Closed
hxgdzyuyi opened this issue Dec 2, 2022 · 2 comments
Closed

Comments

@hxgdzyuyi
Copy link

hxgdzyuyi commented Dec 2, 2022

I found go-policyd while searching for how to handle "unexpected read from socket" error with go-mysql-driver.

I found "unexpected read from socket" in go-policyd's RREADME.md.

I'd like to ask you how you debug this error at that time, thank you.

@thc2cat
Copy link
Owner

thc2cat commented Dec 2, 2022

Hello.

Db reconnection is done after db.Exec Failure by the db lib,
when encountering db.Ping error, go-policyd respond DUNNO to avoid mail rejection due to database connection issue.

Connection is usualy lost when mariadb is upgraded and/or restarted.

    dberr := db.Ping()
if dberr != nil {
	xlog.Err("Skipping policyVerify db.Ping Error: " + dberr.Error())
	// Ref : https://github.com/go-sql-driver/mysql/issues/921
	db.Exec("SELECT NOW()") // Generate an error for db recovery
	return "DUNNO"          // always return DUNNO on error
}

@hxgdzyuyi
Copy link
Author

thanks @thc2cat

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