mysql 主从复制
build grpc
一次tcp错误排查
一个使用php的workman的代码抛出了这样的异常
fwrite(): send of 157 bytes failed with errno=11 Resource temporarily unavailable
socket是使用了noblocking的,结果有一个这个错误,结果发现是已经修复了不抛异常了,但是在我的php5.6的版本还是旧的代码,所以还是会抛这个异常,所以排查了一天,不是bug 最新的修改
https://github.com/php/php-src/pull/5026/files
didwrite = send(sock->socket, buf, XP_SOCK_BUF_SIZE(count), (sock->is_blocked && ptimeout) ? MSG_DONTWAIT : 0);
if (didwrite <= 0) {
char *estr;
int err = php_socket_errno();
if (err == EWOULDBLOCK || err == EAGAIN) {
if (sock->is_blocked) {
int retval;
sock->timeout_event = 0;
do {
retval = php_pollfd_for(sock->socket, POLLOUT, ptimeout);
if (retval == 0) {
sock->timeout_event = 1;
break;
}
if (retval > 0) {
/* writable now; retry */
goto retry;
}
err = php_socket_errno();
} while (err == EINTR);
} else {
/* EWOULDBLOCK/EAGAIN is not an error for a non-blocking stream.
* Report zero byte write instead. */
return 0;
}
}
estr = php_socket_strerror(err, NULL, 0);
php_error_docref(NULL, E_NOTICE, "Send of " ZEND_LONG_FMT " bytes failed with errno=%d %s",
(zend_long)count, err, estr);
efree(estr);
}
if (didwrite > 0) {
php_stream_notify_progress_increment(PHP_STREAM_CONTEXT(stream), didwrite, 0);
}
return didwrite;
}
论文的有趣性
心跳和tcp
c++ 标准库的vector
c++的标准库也没有银弹,也是写出来的,至少消除了我的恐惧
相关阅读
mysqlbinlog
如何读取mysql的binlog?
可以使用mysql默认的mysqlbinlog
重要的是需要加v
命令
mysqlbinlog -v mysql-bin.000006
你会看到具体的sql了,我这里的sql是
#210311 14:51:10 server id 1 end_log_pos 1606 CRC32 0x783f56ab Query thread_id=64 exec_time=0 error_code=0
SET TIMESTAMP=1615445470/*!*/;
BEGIN
/*!*/;
# at 1606
#210311 14:51:10 server id 1 end_log_pos 1672 CRC32 0x52632df5 Table_map: `user_db`.`tb_user` mapped to number 119
# at 1672
#210311 14:51:10 server id 1 end_log_pos 1783 CRC32 0xf565f574 Update_rows: table id 119 flags: STMT_END_F
BINLOG '
3r1JYBMBAAAAQgAAAIgGAAAAAHcAAAAAAAEAB3VzZXJfZGIAB3RiX3VzZXIABgMPDw8BDwgUAEAA
FAAyADj1LWNS
3r1JYB8BAAAAbwAAAPcGAAAAAHcAAAAAAAEAAgAG///AYAAAAAI5NgYxMjM0NTYFOTk5OTcSD3po
YW5nc2FuQGJ1Zy5jbsBgAAAAATUGMTIzNDU2BTk5OTk3Eg96aGFuZ3NhbkBidWcuY2509WX1
'/*!*/;
### UPDATE `user_db`.`tb_user`
### WHERE
### @1=96
### @2='96'
### @3='123456'
### @4='99997'
### @5=18
### @6='zhangsan@bug.cn'
### SET
### @1=96
### @2='5'
### @3='123456'
### @4='99997'
### @5=18
### @6='zhangsan@bug.cn'
# at 1783
#210311 14:51:10 server id 1 end_log_pos 1814 CRC32 0xa90279ec Xid = 1794
COMMIT/*!*/;
SET @@SESSION.GTID_NEXT= 'AUTOMATIC' /* added by mysqlbinlog */ /*!*/;
DELIMITER ;
# End of log file
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;
协议流程
COM_BINLOG_DUMP -> com_binlog_dump
相关阅读
https://www.cnblogs.com/netsa/p/7350629.html https://dev.mysql.com/doc/internals/en/replication-protocol.html
docker-compose spec
docker-compose 的spec
TOP :
version
service
network
volumes
config
secrets
service : build deploy
Each service MAY also include a Build section, which defines how to create the Docker image for the service. Compose implementations MAY support building docker images using this service definition. If not implemented the Build section SHOULD be ignored and the Compose file MUST still be considered valid.
Build support is an OPTIONAL aspect of the Compose specification, and is described in detail here
Each Service defines runtime constraints and requirements to run its containers. The deploy section groups these constraints and allows the platform to adjust the deployment strategy to best match containers' needs with available resources.
相关文档
如何写一个正确的代码
我们如何写一个正确的代码?
答案是形式化验证,其中一个是霍尔逻辑
举个例子
快速幂
x> 0
x/2/2 ... 必定会归到1 或者0, 所以递归会有限次
快速幂
a^x = floor(a^(x/2))^2 *a^(x%1);
fun(a,x) ={
if(x== 0){
return 1;
}elseif(x== 1){
return a;
}
return fun(a , floor(x/2) )*a^(x%1);
}