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

refactor logs [T836] #275

merged 7 commits into from Oct 29, 2018


None yet
2 participants
Copy link

Lagovas commented Oct 25, 2018

  • use pre-generated data for tests. previously generating data took 0.x ms, now 0.000x-0.0000x ms, but actually it not decrease time of tests so much as expected :(
  • log pid of process on start Acra[Server|Connector|Translator|WebConfig]. was need to test restart and decided that it may be useful in a future
  • use our wrapper of net.Dial/Listenen from network package to add ability globally wrap all connections in project with our logic (added wrapper that ensure that conn.Close will called only once to avoid "i/o operation on closed connection" error)
  • use debug log level for all errors that depends on network (closed connection, unavailable network, etc) that will catched and handled on high level function of processing connection (instead lower level with packet parsing/decryption/acra checks). Use error log level only in cases when sure that it unexpected behavior.
  • stop accepting connections after error and stop AcraServer instead infinite loop with trying to accept connections even when listening socket was closed
  • handle COM_QUIT(postgresql)/TerminatePacket(mysql) packets separately to correctly handle closing connections from client app
  • increase timeout for sql statements in tests from 1s to 5s (some tests fail due to timeout to execute queries directly to db)

after these changes we should not to see error messages after simple actions like connect/disconnect with psql/mysql cli commands or pg_isready (in debug mode will see)

Lagovas added some commits Oct 24, 2018

@@ -120,20 +120,29 @@ func (clientSession *ClientSession) HandleClientConnection(clientID []byte, decr
go pgProxy.PgDecryptStream(clientSession.config.censor, decryptorImpl, clientSession.config.GetTLSConfig(), clientSession.connectionToDb, clientSession.connection, dbProxyErrorCh)
var channelToWait chan error
const (
acraDbSide = "AcraServer<->Database"

This comment has been minimized.

for {
select {
case err = <-dbProxyErrorCh:
clientSession.logger.WithError(err).Debugln("error from db proxy")
clientSession.logger.Debugln("Stop to proxy Database -> AcraServer")
interruptSide = acraDbSide

This comment has been minimized.

@@ -300,12 +302,23 @@ func (packet *PacketHandler) ReadClientPacket() error {
switch packetBuf[0] {
// all known message types with flags (F) or (F/B) on
case 'X', 'S', 'p', 'F', 'H', 'E', 'D', 'f', 'c', 'd', 'C', 'B', 'Q':
case 'S', 'p', 'F', 'H', 'E', 'D', 'f', 'c', 'd', 'C', 'B', 'Q':

This comment has been minimized.


vixentael Oct 25, 2018


Why did you remove X?

This comment has been minimized.


vixentael Oct 25, 2018


got it. X is terminate packet, right?

This comment has been minimized.


Lagovas Oct 25, 2018

Author Collaborator


@Lagovas Lagovas merged commit 4939351 into cossacklabs:master Oct 29, 2018

1 check passed

ci/circleci: x86_64 Your tests passed on CircleCI!

@Lagovas Lagovas deleted the Lagovas:lagovas/T836-refactor-logs branch Nov 2, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment