I have a Cockroach DB on Kubernetes (AWS) and a python code to load some data based on psycopg2. But when I try to run a complex query on a 100K rows of data getting connection breakage after some waiting with the following error:
psycopg2.DatabaseError: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
The only suspicious records in the Cockroach logs is a warding:
vendor/google.golang.org/grpc/server.go:666 grpc: Server.Serve failed to create ServerTransport: connection error: desc = "transport: http2Server.HandleStreams failed to receive the preface from client: EOF"
Initially, I thought that connection the issues is in psycopg2.connection
object and added keepalives_
parameters to the connect()
call. And even built some custom connection function which triggers simple SQL query to check if the connection is still open.
But it seems that server itself breaks it as an exception is raised during the cursor.execute(sql_query)
is running.
Any thoughts why such may happen?