1
WriteBatchによって多くの変更を書き込むと、別のスレッドがディスクへの書き込みの途中で読み込まれず、いくつかの新しい値といくつかの古い値で終了するという保証があります変更する)?leveldb WriteBatchアイソレーション
ドキュメントでは、WriteBatchはアトミック(すべてまたは何もない)ですが、分離についてはどうですか?
WriteBatchによって多くの変更を書き込むと、別のスレッドがディスクへの書き込みの途中で読み込まれず、いくつかの新しい値といくつかの古い値で終了するという保証があります変更する)?leveldb WriteBatchアイソレーション
ドキュメントでは、WriteBatchはアトミック(すべてまたは何もない)ですが、分離についてはどうですか?
アイソレーションが保証されています。それは[last_sequence + 1, last_sequence + Count(updates)]
を申請し、書き込みバッチの手順だし、すべての更新操作が行われた後のシーケンスを適用します
WriteBatch* updates = BuildBatchGroup(&last_writer);
WriteBatchInternal::SetSequence(updates, last_sequence + 1);
last_sequence += WriteBatchInternal::Count(updates);
// Add to log and apply to memtable. We can release the lock
// during this phase since &w is currently responsible for logging
// and protects against concurrent loggers and concurrent writes
// into mem_.
{
mutex_.Unlock();
status = log_->AddRecord(WriteBatchInternal::Contents(updates));
bool sync_error = false;
if (status.ok() && options.sync) {
status = logfile_->Sync();
if (!status.ok()) {
sync_error = true;
}
}
if (status.ok()) {
status = WriteBatchInternal::InsertInto(updates, mem_);
}
mutex_.Lock();
if (sync_error) {
// The state of the log file is indeterminate: the log record we
// just added may or may not show up when the DB is re-opened.
// So we force the DB into a mode where all future writes fail.
RecordBackgroundError(status);
}
}
if (updates == tmp_batch_) tmp_batch_->Clear();
versions_->SetLastSequence(last_sequence);
:
は、以下のコードを見てみましょう。つまり、読み取り操作では、バッチが完了する前にシーケンス< = last_sequence
を取得できます。また、バッチがwalとmemtableにコミットされた後にシーケンス> = last_sequence + Count(updates)
を取得できます。
他の[forum](https://groups.google.com/forum/#!topic/leveldb/qp67jTW5Yb8)で矛盾した回答があります: "... Get/Scanコールで指定されたすべてのデータを取得しますシーケンス番号... "あなたはそこで議論を始めることができるので、真実を判断することができます:) – ren
ああ、私はそれを見て、それは我々がここに得た相違は、更新が同じシーケンスまたは異なるシーケンス:)後で議論するでしょう... –
私は間違っていることを知って申し訳ありません、私は私の答えを変更します... –