1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-07-15 01:04:37 +02:00

Binary protocol.

Switch from JSON-based to binary protocol for communicating with local and remote process. The pack type is used to implement the binary protocol.

There are a number advantages:

* The pack type is more compact than JSON and are more efficient to render/parse.
* Packs are more strictly typed than JSON.
* Each protocol message is written entirely within ProtocolServer/ProtocolClient so is less likely to get interrupted by an error and leave the protocol in a bad state.
* There is no limit on message size. Previously this was limited by buffer size without a custom implementation, as was done for read/writing files.

Some cruft from the Perl days was removed, specifically allowing NULL messages and stack traces. This is no longer possible in C.

There is room for improvement here, in particular locking down the allowed sequence of protocol messages and building a state machine to enforce it. This will be useful for resetting the protocol when it gets in a bad state.
This commit is contained in:
David Steele
2021-06-24 13:31:16 -04:00
committed by GitHub
parent bffb43ea3f
commit 6a1c0337dd
41 changed files with 1397 additions and 1227 deletions

View File

@ -1322,14 +1322,15 @@ testRun(void)
// Create job that skips file
job = protocolParallelJobNew(VARSTRDEF("pg_data/test"), protocolCommandNew(strIdFromZ(stringIdBit5, "x")));
VariantList *result = varLstNew();
varLstAdd(result, varNewUInt64(backupCopyResultNoOp));
varLstAdd(result, varNewUInt64(0));
varLstAdd(result, varNewUInt64(0));
varLstAdd(result, NULL);
varLstAdd(result, NULL);
PackWrite *const resultPack = protocolPackNew();
pckWriteU32P(resultPack, backupCopyResultNoOp);
pckWriteU64P(resultPack, 0);
pckWriteU64P(resultPack, 0);
pckWriteStrP(resultPack, NULL);
pckWriteStrP(resultPack, NULL);
pckWriteEndP(resultPack);
protocolParallelJobResultSet(job, varNewVarLst(result));
protocolParallelJobResultSet(job, pckReadNewBuf(pckWriteBuf(resultPack)));
// Create manifest with file
Manifest *manifest = manifestNewInternal();