Isolation ist garantiert.
Werfen Sie einen Blick auf den Code unten:
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);
Das Verfahren von Schreib Partie ist, ist es für [last_sequence + 1, last_sequence + Count(updates)]
gelten, und die Sequenz anwenden, nachdem die alle Update-Operation durchgeführt. Dies bedeutet, dass die Leseoperation die Sequenz < = last_sequence
vor dem Abschluss der Stapelverarbeitung abrufen kann, oder rufen Sie die Sequenz> = last_sequence + Count(updates)
ab, nachdem die Stapelverarbeitung sowohl auf wal als auch auf memtable festgelegt wurde.
Hm, habe widersprüchliche Antwort in einem anderen [Forum] (https://groups.google.com/forum/#!topic/leveldb/qp67jTW5Yb8): "... Get/Scan-Aufruf nimmt alle Daten bis zu einem bestimmten Sequenznummer ... "Du könntest dort eine Debatte beginnen, damit die Wahrheit ermittelt werden kann :) – ren
hah, ich habe mir das angeschaut, es scheint, dass die Divergenz, die wir hier bekommen haben, dass die Updates die gleiche Sequenz oder verschiedene Sequenzen haben :) i werde später debattieren ... –
Es tut mir leid zu finden, dass ich falsch liege, ich werde meine Antwort ändern ... –