PG服务进程(Postgres)——向前端发送后端cancellation

网友投稿 681 2022-11-13

PG服务进程(Postgres)——向前端发送后端cancellation

PG服务进程(Postgres)——向前端发送后端cancellation

BackendKeyData 此消息提供了前端必须保存的密钥数据,以便以后能够发出取消请求。 前端不应响应此消息,而应继续侦听 ReadyForQuery 消息。This message provides secret-key data that the frontend must save if it wants to be able to issue cancel requests later. The frontend should not respond to this message, but should continue listening for a ReadyForQuery message.

/* Send this backend's cancellation info to the frontend. */ if (whereToSendOutput == DestRemote){ StringInfoData buf; pq_beginmessage(&buf, 'K'); pq_sendint32(&buf, (int32) MyProcPid); pq_sendint32(&buf, (int32) MyCancelKey); pq_endmessage(&buf); /* Need not flush since ReadyForQuery will do it. */ }

MyCancelKey来源于哪里呢? 在​​​static int BackendStartup(Port *port)​​​函数中调用​​RandomCancelKey(&MyCancelKey)​​,RandomCancelKey计算将分配给此后端的取消键。

static bool RandomCancelKey(int32 *cancel_key){ return pg_strong_random(cancel_key, sizeof(int32));}

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:MyBatis 多个条件使用Map传递参数进行批量删除方式
下一篇:PG服务进程(Postgres)——idle告诉前端准备好接受查询
相关文章

 发表评论

暂时没有评论,来抢沙发吧~