<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>DB on Bad Fd</title>
    <link>/categories/db/</link>
    <description>Recent content in DB on Bad Fd</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>zh-cn</language>
    <lastBuildDate>Mon, 29 Mar 2021 00:00:00 +0000</lastBuildDate><atom:link href="/categories/db/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>类redis-list的持久化编码和复杂度分析</title>
      <link>/posts/db_%E7%B1%BBredis-list%E7%9A%84%E6%8C%81%E4%B9%85%E5%8C%96%E7%BC%96%E7%A0%81%E5%92%8C%E5%A4%8D%E6%9D%82%E5%BA%A6%E5%88%86%E6%9E%90/</link>
      <pubDate>Mon, 29 Mar 2021 00:00:00 +0000</pubDate>
      
      <guid>/posts/db_%E7%B1%BBredis-list%E7%9A%84%E6%8C%81%E4%B9%85%E5%8C%96%E7%BC%96%E7%A0%81%E5%92%8C%E5%A4%8D%E6%9D%82%E5%BA%A6%E5%88%86%E6%9E%90/</guid>
      <description></description>
    </item>
    
    <item>
      <title>rocksdb的blockcache的一些优化点</title>
      <link>/posts/db_rocksdb%E7%9A%84blockcache%E7%9A%84%E4%B8%80%E4%BA%9B%E4%BC%98%E5%8C%96%E7%82%B9/</link>
      <pubDate>Fri, 26 Mar 2021 00:00:00 +0000</pubDate>
      
      <guid>/posts/db_rocksdb%E7%9A%84blockcache%E7%9A%84%E4%B8%80%E4%BA%9B%E4%BC%98%E5%8C%96%E7%82%B9/</guid>
      <description>&lt;h1 id=&#34;引子&#34;&gt;引子&lt;/h1&gt;
&lt;p&gt;记一些突然间的想法，防止后续忘了，以下是正文。&lt;/p&gt;
&lt;h1 id=&#34;blockcahe的问题&#34;&gt;blockcahe的问题&lt;/h1&gt;
&lt;p&gt;rocksdb的blockcache目前遇到的，主要有：&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;官方实现中没有回收机制.&lt;/li&gt;
&lt;/ol&gt;</description>
    </item>
    
    <item>
      <title>lsm读写放大分析（r1）</title>
      <link>/posts/db_lsm%E8%AF%BB%E5%86%99%E6%94%BE%E5%A4%A7%E5%88%86%E6%9E%90r1/</link>
      <pubDate>Tue, 23 Mar 2021 00:00:00 +0000</pubDate>
      
      <guid>/posts/db_lsm%E8%AF%BB%E5%86%99%E6%94%BE%E5%A4%A7%E5%88%86%E6%9E%90r1/</guid>
      <description></description>
    </item>
    
    <item>
      <title>lsm读写放大分析（r2）</title>
      <link>/posts/db_lsm%E8%AF%BB%E5%86%99%E6%94%BE%E5%A4%A7%E5%88%86%E6%9E%90r2/</link>
      <pubDate>Tue, 23 Mar 2021 00:00:00 +0000</pubDate>
      
      <guid>/posts/db_lsm%E8%AF%BB%E5%86%99%E6%94%BE%E5%A4%A7%E5%88%86%E6%9E%90r2/</guid>
      <description></description>
    </item>
    
    <item>
      <title>wal recovery would cleanup at least the first WAL</title>
      <link>/posts/db_wal-recovery-would-cleanup-at-least-the-first-wal/</link>
      <pubDate>Tue, 09 Mar 2021 00:00:00 +0000</pubDate>
      
      <guid>/posts/db_wal-recovery-would-cleanup-at-least-the-first-wal/</guid>
      <description>&lt;p&gt;这段时间跟同事尝试修复长期以来项目中遗留的Rocksdb的Case，遇到些有意思的Case，这里记录一下。&lt;/p&gt;
&lt;h2 id=&#34;heading&#34;&gt;&lt;/h2&gt;
&lt;h2 id=&#34;some-tips-for-rocksdb-case-fixing&#34;&gt;some tips for rocksdb case fixing&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;对于不支持&lt;code&gt;-march=native&lt;/code&gt;环境的，可以编译时&lt;code&gt;export USE_SSE=1&lt;/code&gt;.避免类似&lt;code&gt;no such instruction: &lt;/code&gt;shlx %r13,%rax,%rax&#39;`的问题。&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;对于rocksdb的测试case，想保留测试db的，可以搞个&lt;code&gt;KEEP_DB&lt;/code&gt;环境变量。测试类会根据这个环境变量决定是否清理测试DB。&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;</description>
    </item>
    
    <item>
      <title>some details about rocksdb::LRUCache</title>
      <link>/posts/db_some-details-about-rocksdblrucache/</link>
      <pubDate>Mon, 08 Mar 2021 00:00:00 +0000</pubDate>
      
      <guid>/posts/db_some-details-about-rocksdblrucache/</guid>
      <description>&lt;p&gt;最近有同事找我讨论问题，觉得挺有趣的记录一下。&lt;/p&gt;
&lt;h3 id=&#34;rocksdblruhandlekey的历史&#34;&gt;&lt;code&gt;rocksdb::LRUHandle::key()&lt;/code&gt;的历史&lt;/h3&gt;
&lt;p&gt;第一个问题是&lt;code&gt;rocksdb::LRUHandle::key()&lt;/code&gt;, 这个函数返回该handle内部存储的key，但为啥某些情况下却返回value呢？&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>db笔记 - 事务1:隔离级别</title>
      <link>/posts/db_txn_lec1/</link>
      <pubDate>Sun, 14 Feb 2021 00:00:00 +0000</pubDate>
      
      <guid>/posts/db_txn_lec1/</guid>
      <description>&lt;h2 id=&#34;锁&#34;&gt;锁&lt;/h2&gt;
&lt;p&gt;read lock
write lock
long duration lock
short duration lock&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>db笔记 - sse</title>
      <link>/posts/db_talk_about_sse/</link>
      <pubDate>Mon, 01 Feb 2021 00:00:00 +0000</pubDate>
      
      <guid>/posts/db_talk_about_sse/</guid>
      <description>&lt;h2 id=&#34;background&#34;&gt;background&lt;/h2&gt;
&lt;blockquote&gt;
&lt;p&gt;we would set env var &lt;code&gt;USE_SSE=1&lt;/code&gt; when compiling Rocksdb, OTHERWISE it would always failed
at linking stage where encountering errors of lack of some instructions such as:
&lt;code&gt;no such instruction: &lt;/code&gt;shlx %rdx,%rax,%rax&#39;`.
but what the fuck is USE_SSE ?&lt;/p&gt;
&lt;/blockquote&gt;</description>
    </item>
    
    <item>
      <title>笔记：一些日常cheatsheet</title>
      <link>/posts/db_dailywork_cheatsheet/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/posts/db_dailywork_cheatsheet/</guid>
      <description>&lt;p&gt;日常cheatsheet～&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;run valgrind for a program&lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;code&gt;valgrind --tool=memcheck --leak-check=full --log-file=leak.log --soname-synonyms=somalloc=NONE &amp;lt;some_exe&amp;gt; [&amp;lt;some_exe_args&amp;gt;]
&lt;/code&gt;&lt;/pre&gt;&lt;ul&gt;
&lt;li&gt;run tcpdump to capture mysql queries:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;code&gt;tcpdump -r /tmp/a.cap -A -S -n -nn  | grep -i -E &amp;quot;select|insert|update|delete|replace&amp;quot; | sed &#39;s%\(.*\)\([.]\{4\}\)\(.*\)%\3%&#39; | less
&lt;/code&gt;&lt;/pre&gt;&lt;ul&gt;
&lt;li&gt;python scripts:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;code&gt;python -m SimpleHTTPServer 8123
wget -c -r -nH -m --limit-rate=400m &amp;quot;http://ip:8123/xxxx&amp;quot;
&lt;/code&gt;&lt;/pre&gt;&lt;pre&gt;&lt;code&gt;python -c &#39;from zlib import crc32; print crc32(&amp;quot;1476777&amp;quot;) % 1024&#39;
&lt;/code&gt;&lt;/pre&gt;&lt;pre&gt;&lt;code&gt;#!/usr/bin/python
# -*- coding: UTF-8 -*-
import sys
import json
data = &amp;quot;&amp;quot;
for line in sys.stdin:
        data += line
text = json.loads(data)
print(text)
&lt;/code&gt;&lt;/pre&gt;&lt;ul&gt;
&lt;li&gt;&lt;code&gt;tee&lt;/code&gt; with a pipe output to screen and a file&lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;code&gt;echo &amp;quot;hello&amp;quot; | tee abc.txt
&lt;/code&gt;&lt;/pre&gt;&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;ps&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;top&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;tasr&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;sar&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;</description>
    </item>
    
  </channel>
</rss>
