Free To Feel

    Deal with mysql ERROR 1005 (HY000)

    How to deal with 'mysql ERROR 1005 (HY000): Can't create table '' (errno: 150)'? Usuall it was caused by mysql foreign key. But how you know which foreign key is wrong? Or why it is incorrect? To get more information, you can execute:

    SHOW ENGINE INNODB STATUS\G
    . In my case:

    CREATE TABLE `table3`
    (
      `id` INTEGER  NOT NULL AUTO_INCREMENT,
      `name` VARCHAR(255),
      `author_id` INTEGER  NOT NULL,
      `is_published` TINYINT default 0,
      `identifier` VARCHAR(100),
      `path` VARCHAR(255),
      `description` TEXT,
      PRIMARY KEY (`id`),
      KEY `books_I_1`(`is_published`),
      INDEX `books_FI_1` (`author_id`),
      CONSTRAINT `books_FK_1`
        FOREIGN KEY (`author_id`)
        REFERENCES `users` (`id`)
        ON DELETE SET NULL
    )Type=InnoDB
    

    I get mysql 1005 error with above sql, if I execute show innodb status, I will get:

    =====================================
    110121 16:11:12 INNODB MONITOR OUTPUT
    =====================================
    Per second averages calculated from the last 13 seconds
    ----------
    SEMAPHORES
    ----------
    OS WAIT ARRAY INFO: reservation count 28, signal count 28
    Mutex spin waits 0, rounds 81, OS waits 4
    RW-shared spins 38, OS waits 19; RW-excl spins 5, OS waits 5
    ------------------------
    LATEST FOREIGN KEY ERROR
    ------------------------
    110121 16:05:56 Error in foreign key constraint of table table3:
    
       FOREIGN KEY (`author_id`)
       REFERENCES `users` (`id`)
       ON DELETE SET NULL
    )Type=InnoDB:
    You have defined a SET NULL condition though some of the
    columns are defined as NOT NULL.
    

    Yes, as you can see, the last sentence is what I want. Actually, I define author_id can not be null. Good luck to you.

    Cross Lanaguage Service Development

    Thrift is a software framework for scalable cross-language services development. Now it supports C++, C#, Erlang, Haskell, Java, Objective C/Cocoa, OCaml, Perl, PHP, Python, Ruby, and Squeak.

    So basically, what you need to do is define a .thrift definition file. And Thrift will help you generate the RPC client and RPC server. There are a lot of examples in this wiki page.

    You can use this demo to understand how it works.

    There is a similar project called Protocol Buffers which provided by google.


    This is what I have done in todays' Innovation Day. And I totall agree:

    Individuals and interactions over processes and tools

    We know people is the kernel in a technical company. Anything is beneficial for people should be encouraged. But of course, it also should be beneficial for company firstly. Any rule that restrict people's mind should be removed.

    年末总结

    又到岁末了,这一年最大的感触就是世界在变,变得太快。我一直在想七八十岁的老人生活在这个年代,坐着更现代的交通工具,吃着更美味的美食,眼睁睁的目睹人的行为的变化。他们会怎么看这个时代。我现在有点同感了。

    以前从未有个new year todo list,但从工作实践中感觉这个确实还有有些效果和意义的(以前我最讨厌形式上的东西的)。

    2010 完成和进行中的事情

    • kiwitask.com 年初改版上线,几次尝试都失败,最后直接将其下线。有意思的事情对这个产品的反省和思索是事情过去了几个月之后才渐渐体会到的;
    • 终于在高房价的矛盾中购房一套;
    • 开始学车历程,临近过节看着各式各样的车祸,心头一寒,不学好真不敢出来开;
    • 有幸成为SM,依然在实践中继续学习,汲取前人的经验和教训,希望不要误人子弟;
    • 做了一次国内远徒旅行,太简单了;

    2011 TO DO LIST

    • 结婚,自己都觉得不好意思了;
    • 下半年装修;
    • 完成学车;
    • 回家把护照给办了;
    • 上线一个新的产品, 如果有精力将其它几个产品打包上线;
    • 在互联网上混的更实在,看到这领域太多的肤浅和吹嘘;
    • 寻找一种锻炼身体的方式,这个是最急切的任务;
    • 希望可以在工作中做的更多,得到更大的认可。
    • 和亲戚朋友多联系,2010年,我们联系的太少了;
    • 争取做一次说的过去的远徒旅行或者国外旅行一次 :-);
    • 多写点有价值的文章

    2011 WISH LIST

    • 冤案越来越少,人心越来越温暖,没有欺骗,诚实进步的社会;

    Be Careful Of Your Memcached Slab Size

    Recently, we found a very 'strange' bug. The memcached's evictions keep growing. But there is stil 10% free memory in this instance. The memcached instance size is around 600M, and it has recached 90% percentage usage for a long time. This issue happened after we deployed a fix, which changed the entry size stored in memcache.

    Let's give a brief analysis: Memcached memory allocation: a slab has many pages. One page has many chunks. Each chunk is a fixed size, based on the maximum size for the slab. So for example, there is 600Mb memory for the whole instance. And there are 540Mb has been used. Usually you store some big entries into memcache. Let's say 1500 bytes for each of them. So there are some big slabs with chunk size from 1000 bytes to 2000 bytes. And these slabs took 400Mb memory. Now you changed the size for these entries to 500 bytes. Let's call these entries 'Changed-Entries'. So memcached try to find some slabs which have 500 bytes size chunk. There are three possibilities:

    1. There is no such size slabs exist. So Memcached will use the free memory to create some proper size slab for 'Changed-Entries'; There are 60Mb free memory can be used. But if these entries need 100Mb. That means some old entries will be 'kicked out' from these new slabs. Eviction happens;

    2. If memcached found some used slabs which have 500 bytes chunk. It will kickout the expired items firstly. If the memroy still not enough for 'Changed-Entries', then the least used entries will be kicked out. Eviction happens;

    3. If there is no free memory and there is no propel slabs can be used, then eviction happens.

    If you want to learn more detail about how it works, take a look following references:

    Dig Into Nodejs

    Just find a beautiful and simplest javascript code:

      // In both HTTP servers and clients it is possible to queue up several
      // outgoing messages. This is easiest to imagine in the case of a client.
      // Take the following situation:
      //
      //    req1 = client.request('GET', '/');
      //    req2 = client.request('POST', '/');
      //
      // The question is what happens when the user does
      //
      //   req2.write("hello world\n");
      //
      // It's possible that the first request has not been completely flushed to
      // the socket yet. Thus the outgoing messages need to be prepared to queue
      // up data internally before sending it on further to the socket's queue.
      //
      // This function, outgoingFlush(), is called by both the Server
      // implementation and the Client implementation to attempt to flush any
    
    
      while (message.output.length) {
        if (!socket.writable) return; // XXX Necessary?
    
        var data = message.output.shift();
        var encoding = message.outputEncodings.shift();
    
        ret = socket.write(data, encoding);
      }
    

    Now I know how nodejs talk with server, which is using Socket.IO - multi-transport socket server.

    Find Ubuntu Wireless Icon

    My network-manager works fine. You can test by sudo service network-manager start/stop. And my wireless network can be found by sudo iwlist scan. So there are two solutions:

    • Right click the top panel and click 'add to panel' and select 'notifications area'. If this didn't work,then netstep:
    • sudo vim /etc/NetworkManager/nm-sysmte-settings.conf. Modify false to true. sudo service network-manager restart In my ubuntu 10.10, after these trys, the wireless icon displayed in the panel again. Good luck to you.

    Try to Use Github Pages As My Blog

    Finally, I decide to move my blog to githubpages. I know github do a great job. I want to give a try.
    Later I will try to import my old blog entries.
    Until now, everything looks amazing.


    I finished the import from wordpress blog to github. I make a import.php script. Don’t forget to change the user name, password and database in this script.


    Add comment service into my blog.