|
| 1 | +## PostgreSQL 15 preview - pg_basebackup 增强, 支持扩展COPY协议 |
| 2 | + |
| 3 | +### 作者 |
| 4 | +digoal |
| 5 | + |
| 6 | +### 日期 |
| 7 | +2022-01-19 |
| 8 | + |
| 9 | +### 标签 |
| 10 | +PostgreSQL , pg_basebackup |
| 11 | + |
| 12 | +---- |
| 13 | + |
| 14 | +## 背景 |
| 15 | +pg_basebackup 扩展协议, 将来将支持更好的进度展示、压缩格式、等. |
| 16 | + |
| 17 | +https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=cc333f32336f5146b75190f57ef587dff225f565 |
| 18 | + |
| 19 | +``` |
| 20 | +Modify pg_basebackup to use a new COPY subprotocol for base backups. |
| 21 | +author Robert Haas <[email protected]> |
| 22 | +Tue, 18 Jan 2022 18:47:26 +0000 (13:47 -0500) |
| 23 | +committer Robert Haas <[email protected]> |
| 24 | +Tue, 18 Jan 2022 18:47:49 +0000 (13:47 -0500) |
| 25 | +commit cc333f32336f5146b75190f57ef587dff225f565 |
| 26 | +tree 8bcc3bf1b50cf4cbfe597a519b37e7aa8fcc5bde tree |
| 27 | +parent 3414099c338bf619c00dd82d96f29a9668a3bf07 commit | diff |
| 28 | +Modify pg_basebackup to use a new COPY subprotocol for base backups. |
| 29 | + |
| 30 | +In the new approach, all files across all tablespaces are sent in a |
| 31 | +single COPY OUT operation. The CopyData messages are no longer raw |
| 32 | +archive content; rather, each message is prefixed with a type byte |
| 33 | +that describes its purpose, e.g. 'n' signifies the start of a new |
| 34 | +archive and 'd' signifies archive or manifest data. This protocol |
| 35 | +is significantly more extensible than the old approach, since we can |
| 36 | +later create more message types, though not without concern for |
| 37 | +backward compatibility. |
| 38 | + |
| 39 | +The new protocol sends a few things to the client that the old one |
| 40 | +did not. First, it sends the name of each archive explicitly, instead |
| 41 | +of letting the client compute it. This is intended to make it easier |
| 42 | +to write future patches that might send archives in a format other |
| 43 | +that tar (e.g. cpio, pax, tar.gz). Second, it sends explicit progress |
| 44 | +messages rather than allowing the client to assume that progress is |
| 45 | +defined by the number of bytes received. This will help with future |
| 46 | +features where the server compresses the data, or sends it someplace |
| 47 | +directly rather than transmitting it to the client. |
| 48 | + |
| 49 | +The old protocol is still supported for compatibility with previous |
| 50 | +releases. The new protocol is selected by means of a new |
| 51 | +TARGET option to the BASE_BACKUP command. Currently, the |
| 52 | +only supported target is 'client'. Support for additional |
| 53 | +targets will be added in a later commit. |
| 54 | + |
| 55 | +Patch by me. The patch set of which this is a part has had review |
| 56 | +and/or testing from Jeevan Ladhe, Tushar Ahuja, Suraj Kharage, |
| 57 | +Dipesh Pandit, and Mark Dilger. |
| 58 | + |
| 59 | +Discussion: http://postgr.es/m/CA+TgmoaYZbz0=Yk797aOJwkGJC-LK3iXn+wzzMx7KdwNpZhS5g@mail.gmail.com |
| 60 | +``` |
| 61 | + |
| 62 | +https://www.postgresql.org/docs/devel/protocol-replication.html |
| 63 | + |
| 64 | +``` |
| 65 | +new archive (B) |
| 66 | +Byte1('n') |
| 67 | +Identifes the messaage as indicating the start of a new archive. |
| 68 | + |
| 69 | +String |
| 70 | +The file name for this archive. |
| 71 | + |
| 72 | +String |
| 73 | +For the main data directory, an empty string. For other tablespaces, the full path to the directory from which this archive was created. |
| 74 | + |
| 75 | +manifest (B) |
| 76 | +Byte1('m') |
| 77 | +Identifes the message as indicating the start of the backup manifest. |
| 78 | + |
| 79 | +archive or manifest data (B) |
| 80 | +Byte1('d') |
| 81 | +Identifes the message as containing archive or manifest data. |
| 82 | + |
| 83 | +Byten |
| 84 | +Data bytes. |
| 85 | + |
| 86 | +progress report (B) |
| 87 | +Byte1('p') |
| 88 | +Identifes the message as a progress report. |
| 89 | + |
| 90 | +Int64 |
| 91 | +The number of bytes from the current tablespace for which processing has been completed. |
| 92 | +``` |
| 93 | + |
| 94 | + |
| 95 | + |
| 96 | +#### [期望 PostgreSQL 增加什么功能?](https://github.com/digoal/blog/issues/76 "269ac3d1c492e938c0191101c7238216") |
| 97 | + |
| 98 | + |
| 99 | +#### [PolarDB for PostgreSQL云原生分布式开源数据库](https://github.com/ApsaraDB/PolarDB-for-PostgreSQL "57258f76c37864c6e6d23383d05714ea") |
| 100 | + |
| 101 | + |
| 102 | +#### [PostgreSQL 解决方案集合](https://yq.aliyun.com/topic/118 "40cff096e9ed7122c512b35d8561d9c8") |
| 103 | + |
| 104 | + |
| 105 | +#### [德哥 / digoal's github - 公益是一辈子的事.](https://github.com/digoal/blog/blob/master/README.md "22709685feb7cab07d30f30387f0a9ae") |
| 106 | + |
| 107 | + |
| 108 | + |
| 109 | + |
0 commit comments