Repository: edgedb/edgedb

Issue:
ISE when creating a dump for a server using a shared compiler pool
<!-- Please search existing issues to avoid creating duplicates. -->

<!--
For the EdgeDB Version: run `edgedb query 'select sys::get_version_as_str()'` from your project directory (or run `select sys::get_version_as_str();` in the EdgeDB interactive shell).
For the EdgeDB CLI Version: Run `edgedb --version` from anywhere
-->

- EdgeDB Version: 3.0-dev.7084+local, built from source (rev [0d82c62](https://github.com/edgedb/edgedb/commit/0d82c62bc0eb19fa9e76de35079facad2922fccc))
- EdgeDB CLI Version: 2.3.0, built from source (rev [ad53612](https://github.com/edgedb/edgedb-cli/commit/ad536125a6d3dcd3513f749f881bb0260e22cfe8))

Steps to Reproduce:

1. Start the shared compiler process:
```bash
_EDGEDB_SERVER_COMPILER_POOL_SECRET="secret" edgedb-server compiler
```
2. Start the EdgeDB server pointing to the compiler process:
```bash
_EDGEDB_SERVER_COMPILER_POOL_SECRET="secret" edgedb-server --devmode --data-dir=$(mktemp -d) --tls-cert-mode=generate_self_signed --compiler-pool-mode=remote --compiler-pool-addr=localhost:5660
```
3. Try to create a dump using the CLI:
```bash
./target/debug/edgedb --dsn=edgedb://edgedb:edgedb@localhost:5656/edgedb --tls-security=insecure dump ./db.dump
```
4. Get the error:
```
edgedb error: InternalServerError: error receiving dump header: unpickling stack underflow
  Hint: This is most likely a bug in EdgeDB. Please consider opening an issue ticket at https://github.com/edgedb/edgedb/issues/new?template=bug_report.md
  Server traceback:
      Traceback (most recent call last):
        File "/home/nik/projects/edgedb/edgedb/edb/server/compiler_pool/worker_proc.py", line 46, in worker
          methname, args = pickle.loads(req)
      _pickle.UnpicklingError: unpickling stack underflow
```

Sometimes it can be like this:
```
edgedb error: InternalServerError: error receiving dump header: invalid load key, 'v'.
  Hint: This is most likely a bug in EdgeDB. Please consider opening an issue ticket at https://github.com/edgedb/edgedb/issues/new?template=bug_report.md
  Server traceback:
      Traceback (most recent call last):
        File "/home/nik/projects/edgedb/edgedb/edb/server/compiler_pool/worker_proc.py", line 46, in worker
          methname, args = pickle.loads(req)
      _pickle.UnpicklingError: invalid load key, 'v'.
```


Discussion:

Resolving patch:
diff --git a/edb/server/compiler_pool/server.py b/edb/server/compiler_pool/server.py
--- a/edb/server/compiler_pool/server.py
+++ b/edb/server/compiler_pool/server.py
@@ -434,13 +434,13 @@ async def _request(self, method_name, msg):
     async def handle_client_call(self, protocol, req_id, msg):
         client_id = protocol.client_id
         digest = msg[:32]
-        data = msg[32:]
+        msg = msg[32:]
         try:
-            expected_digest = hmac.digest(self._secret, data, "sha256")
+            expected_digest = hmac.digest(self._secret, msg, "sha256")
             if not hmac.compare_digest(digest, expected_digest):
                 raise AssertionError("message signature verification failed")
 
-            method_name, args = pickle.loads(msg[32:])
+            method_name, args = pickle.loads(msg)
             if method_name != "__init_server__":
                 await self._ready_evt.wait()
             if method_name == "__init_server__":


Test patch: