If we use DB_TXN_NOSYNC instead of DB_TXN_WRITE_NOSYNC, when the process is crash, will the data which has been written but not flush to disk be safe? May we lose data?Both DB_TXN_NOSYNC and DB_TXN_WRITE_NOSYNC sacrifice durability for performance, so you risk losing some committed transactions during a recovery with either option. With DB_TXN_NOSYNC, you risk losing more committed transactions and the number you lose depends on how many updates can fit into the log buffer.
Another question: if the flag DB_LOG_IN_MEMORY is set, synchronization from client to master may be suspended sometimes. I set a key/value to master successfully and can not get the key/value from client. Now I use db_stat to get the stats from client, some error occurs and error message is as follows:This sounds like you have hit a failure before you try to get stats. I will likely need to see what happens right before the client stops getting updates to see what is wrong.
db_stat: PANIC: fatal region error detected; run recovery
db_stat: DB_ENV->open: /data0/mdb/20111/: DB_RUNRECOVERY: Fatal error, run database recovery