Skip to content

Instantly share code, notes, and snippets.

View ideawu's full-sized avatar
🎯

吴祖洋 ideawu

🎯
View GitHub Profile

Linking libstdc++ statically

Christopher Baus writes about his problems linking libstdc++ statically. Yes, making C++ binaries that will work properly in different Linux distributions is somewhat painful. The problem is not so much linking libstdc++ statically – it is just a library, after all – but the runtime support required by C++ code in general, to enable features like RTTI and exception handling.

The runtime support code used by different parts of a C++ application needs to be compatible. If one part of the program needs to dynamic_cast or catch objects provided by another, both parts must agree on certain implementation details: how to find vtables, how to unwind the stack, and so on.

For C++ and a few other GCC-supported languages with similar features, such details are specified by a C++ ABI. Whenever the ABI used by GCC changes you'll end up with incompatible libraries produced by the different GCC versions. The same is true for plain C, but the C ABI is much simpler and has been around a

@ideawu
ideawu / 软件架构设计文档.md
Created February 27, 2021 10:56
软件架构设计文档

设计文档以每一个功能点的时序图为主. 时序图要明确模块的主动和被动关系.

对于定时任务或者异步队列的消费者, 为它们的每一个任务的处理流程画时序图.

@ideawu
ideawu / 多写入点数据同步.md
Last active April 23, 2021 02:43
多写入点数据同步
  • 多个节点组成一个 raft 组
  • 某个组可以作为另一个组的 slave, 从另一组同步 binlog
  • leader 负责从另一个组同步 binlog, followers 从 leader 处同步, 不走 raft
  • 两组 binlog 如何 merge?
@ideawu
ideawu / 数据库事务原子性.md
Last active March 19, 2021 08:02
数据库事务原子性

事务原子性

例如在事务中往一个空集合中 prepare 添加一个元素, 之后, 事务中心已经提交, 但元素仍是 prepared 状态. 如果此时去读这个元素, 可以读到, 向事务中心求证, 发现其是 committed 状态. 但如果去读集合计数, 仍然是 0, 因为元素只在变更为 committed 状态时才更新集合计数.

一个事务, set a=1, set b=2. 如果先读发现 a=1, 然后去读发现 b=0, 这种行为是否违反事务 ACID 的原子性?

如果先读发现 b=0, 再读发现 a=1, 我认为符合原子性. 但反过来我认为不符合, 因为发现 a=1 时, 可以推导出事务已经提交, 既然已经提交, 那么 b=2 也应该已经提交.

为了达到原子性, 应该加上读修复功能. 当读发现 prepare 状态的资源时, 应该尝试修复: 如果确认是 prepared 状态, 立即返回旧值. 如果确认是 committed 状态, 修复(或者等待, 不主动修复), 然后再返回新值.

@ideawu
ideawu / 一致性.md
Created February 26, 2021 05:46
一致性

一致性就是唯一预期. 给定输入条件, 结果是可以确定的. 无论重复多少次, 无论观察多少次, 结果都是唯一的.

@ideawu
ideawu / 数据库最常用的特性.md
Last active May 21, 2021 04:12
数据库最常用的特性

根据我的从业经验, 用户对一个(分布式)数据库系统, 最看重这些特性:

  1. 多副本, 数据安全性
    • 能提供强一致性更好, 但基于性能考虑, 最终一致性(异步复制)有广泛的用户需求
  2. 节点容灾, 部分服务器故障, 不影响整体系统的运行
    • 方案选择, 倾向于增加无状态 proxy 层
  3. "伪装"成一个单机数据库实例, 底层细节对用户隐藏
    • 平滑扩容, 加机器不影响业务, 不需要业务在代码和架构上做改变
  4. 数据全球同步, 最终一致
  • 一个大区的日志序列是顺序 apply, 但多个大区的日志序列是乱序 apply
@ideawu
ideawu / lock_guard.md
Created February 2, 2021 02:48
lock_guard改名为 AutoLock

lock_guard改名为 AutoLock

@ideawu
ideawu / PHP引用变量.md
Created January 21, 2021 02:51
PHP引用变量

PHP 引用变量使用前, 必须重置!

@ideawu
ideawu / 请求处理状态.md
Created January 19, 2021 01:47
请求处理状态
  1. Succ
  2. Fail
  3. Unknown
    • Service timeout
    • Unknown error
@ideawu
ideawu / 数据库需求.md
Created January 5, 2021 07:55
数据库需求
  • 一致性
    • 多副本, 区域强一致
    • 全球同步, 最终一致
  • 高可用(自动化地应对故障)
    • 机器故障检测, 换路由重试
    • 单次请求故障检测, 重试(如果可以重试)
  • 大容量(可能性, 大部分情况当前不需要, 但不排除未来需要)
    • 可利用硬盘
    • 数据 sharding
  • 云服务