vxlan
vxlan 是一个3层协议上加上2层协议的协议 由vetp解析出上面2层协议的报文
vxlan 是一个3层协议上加上2层协议的协议 由vetp解析出上面2层协议的报文
mysql报文分为两部分:header和payload
有四个字节,其中前三个字节是标识这个包的长度描述payload的长度,也就是payload最长的长度为2^24-1字节,最后一个字节则是类似于tcp的序列号,每次从0开始递增,描述的是第几个包
payload则是具体负载
tcp三次握手之后,整个传输层的连接已经建立了,那么怎么登陆呢?
握手文档
加密的方式
举个例子:加密套件是mysql_native_password,那么第一个包会是由 server发出,附带20字节的随机码, 然后在客户端的用户提交的密码做多次sha1哈希然后回传给mysql
1: COM_REGISTER_SLAVE 把slave注册到master里面 2: COM_BINLOG_DUMP 这个包主要是告诉master锁需要的binlog的名字和位点,然后就会返回一堆binlog事件给客户端
int Binlog_sender::get_binlog_end_pos(File_reader *reader, my_off_t *end_pos) {
DBUG_TRACE;
my_off_t read_pos = reader->position();
do {
/*
MYSQL_BIN_LOG::binlog_end_pos is atomic. We should only acquire the
LOCK_binlog_end_pos if we reached the end of the hot log and are going
to wait for updates on the binary log (Binlog_sender::wait_new_event()).
*/
*end_pos = mysql_bin_log.get_binlog_end_pos();
/* If this is a cold binlog file, we are done getting the end pos */
if (unlikely(!mysql_bin_log.is_active(m_linfo.log_file_name))) {
*end_pos = 0;
return 0;
}
DBUG_PRINT("info", ("Reading file %s, seek pos %llu, end_pos is %llu",
m_linfo.log_file_name, read_pos, *end_pos));
DBUG_PRINT("info", ("Active file is %s", mysql_bin_log.get_log_fname()));
if (read_pos < *end_pos) return 0;
/* Some data may be in net buffer, it should be flushed before waiting */
if (!m_wait_new_events || flush_net()) return 1;
if (unlikely(wait_new_events(read_pos))) return 1;
} while (unlikely(!m_thd->killed));
return 1;
}
_attribute_((packed))
你会在redis的sds.h看到这个gcc的扩展属性,这个属性是拿来干嘛呢?其实是拿来压缩字段长度的
This attribute, attached to an enum, struct, or union type definition, specified that the minimum required memory be used to represent the type.
Specifying this attribute for struct and union types is equivalent to specifying the packed attribute on each of the structure or union members. Specifying the -fshort-enums flag on the line is equivalent to specifying the packed attribute on all enum definitions.
You may only specify this attribute after a closing curly brace on an enum definition, not in a typedef declaration, unless that declaration also contains the definition of the enum.
DBUG_PRINT("info", ("Creating new slave thread"));
if (mysql_thread_create(thread_key, &th, &connection_attrib, h_func,
(void *)mi)) {
LogErr(ERROR_LEVEL, ER_RPL_CANT_CREATE_SLAVE_THREAD,
mi->get_for_channel_str());
my_error(ER_SLAVE_THREAD, MYF(0));
goto err;
}
slave 线程
/**
Slave SQL thread entry point.
@param arg Pointer to Relay_log_info object that holds information
for the SQL thread.
@return Always 0.
*/
extern "C" void *handle_slave_sql(void *arg) {
THD *thd; /* needs to be first for thread_stack */
bool thd_added = false;
bool main_loop_error = false;
char llbuff[22], llbuff1[22];
As a special case, the last element of a structure with more than one named member may have an incomplete array type; this is called a flexible array member. With two exceptions, the flexible array member is ignored. First, the size of the structure shall be equal to the offset of the last element of an otherwise identical structure that replaces the flexible array member with an array of unspecified length.106) Second, when a . (or ->) operator has a left operand that is (a pointer to) a structure with a flexible array member and the right operand names that member, it behaves as if that member were replaced with the longest array (with the same element type) that would not make the structure larger than the object being accessed; the offset of the array shall remain that of the flexible array member, even if this would differ from that of the replacement array. If this array would have no elements, it behaves as if it had one element but the behavior is undefined if any attempt is made to access that element or to generate a pointer one past it.
突然间不想写这些业务代码了,就是那么突然.我已经快工作四年了,毫无进展,什么都不会
这几年我究竟做了什么?
给PHP修了两个内存泄漏,相对于写业务,我更喜欢修bug
引入了canal,对binlog更加了解了,而且效果真的很好但是canal其实很多坑.
这些其实很好,但是其他对于我来说都是垃圾时间,我其实真的不喜欢写前端,为什么PHP一定要写前端?
我一点都不会写算法题,真的一点都不会,最近才弄懂循环不变式和霍尔逻辑还有一点点数理逻辑
对于db,我最近才分清隔离级别/事务/mvcc的关系,花了三年半太久了,我也是一年的时候才弄懂PHP关闭连接是什么时候
对于redis其实我根本不懂,我只会简单的set aaa bbb 这样用
对于es,我对分词有所了解因为做过nlp相关需求,但是还是没有用过es
对于我来说,PHP会用,还天天写bug,mysql很多不会用,对于网络,我基本没有用过长连接挺失败的这三年半
对于我这三年半还是挺失败的