cossacklabs / acra

Database security suite. Database proxy with field-level encryption, search through encrypted data, SQL injections prevention, intrusion detection, honeypots. Supports client-side and proxy-side ("transparent") encryption. SQL, NoSQL.
https://www.cossacklabs.com/acra/
Apache License 2.0
1.36k stars 128 forks source link

Fix crash when processing PostgreSQL packets in weird order #505

Closed iamnotacake closed 2 years ago

iamnotacake commented 2 years ago

Also, tiny fix in integration tests so DEBUG_LOG=False env var will really make AcraServer logs less verbose.

Checklist

vixentael commented 2 years ago

shouldn't we use mutex anywhere?

Lagovas commented 2 years ago

shouldn't we use mutex anywhere?

mutexes should be used to synchronize access to shared objects. Here is data related to 2 connections (app <> acra, acra <> db), and handled by 2 goroutines. If 2 goroutines change/update same data - then we should. If only one of them touches data at same time - then we shouldn't. For example if we touch data related to client's side packets in goroutine that work with client side connection, then we can omit mutexes because of opposite goroutine will not touch same data/buffers/processes.