@@ -5853,35 +5853,24 @@ Status DBImpl::IngestExternalFiles(
5853
5853
InstrumentedMutexLock l (&mutex_);
5854
5854
TEST_SYNC_POINT (" DBImpl::AddFile:MutexLock" );
5855
5855
5856
- // Stop writes to the DB by entering both write threads.
5857
- // Even with allow_write = true, writes to the DB must be temporarily
5858
- // stopped to wait for pending writes. This is because allow_write = true
5859
- // only requires users to ensure no concurrent writes overlap with the
5860
- // ingestion data and does not require ensuring no overlapping
5861
- // unordered_write before ingestion.
5862
- WriteThread::Writer w;
5863
- write_thread_.EnterUnbatched (&w, &mutex_);
5864
- WriteThread::Writer nonmem_w;
5865
- if (two_write_queues_) {
5866
- nonmem_write_thread_.EnterUnbatched (&nonmem_w, &mutex_);
5867
- }
5868
-
5869
- // When unordered_write is enabled, the keys are writing to memtable in an
5870
- // unordered way. If the ingestion job checks memtable key range before the
5871
- // key landing in memtable, the ingestion job may skip the necessary
5872
- // memtable flush.
5873
- // So wait here to ensure there is no pending write to memtable.
5874
- WaitForPendingWrites ();
5875
-
5876
- if (allow_write) {
5877
- // If allow_write is true, writes to the DB are resumed here,
5878
- // allowing users to write normally during the subsequent ingest process.
5856
+ if (!allow_write) {
5857
+ // Stop writes to the DB by entering both write threads.
5858
+ WriteThread::Writer w;
5859
+ write_thread_.EnterUnbatched (&w, &mutex_);
5860
+ WriteThread::Writer nonmem_w;
5879
5861
if (two_write_queues_) {
5880
- nonmem_write_thread_.ExitUnbatched (&nonmem_w);
5862
+ nonmem_write_thread_.EnterUnbatched (&nonmem_w, &mutex_ );
5881
5863
}
5882
- write_thread_.ExitUnbatched (&w);
5864
+
5865
+ // When unordered_write is enabled, the keys are writing to memtable in an
5866
+ // unordered way. If the ingestion job checks memtable key range before
5867
+ // the key landing in memtable, the ingestion job may skip the necessary
5868
+ // memtable flush.
5869
+ // So wait here to ensure there is no pending write to memtable.
5870
+ WaitForPendingWrites ();
5883
5871
}
5884
- TEST_SYNC_POINT_CALLBACK (" DBImpl::IngestExternalFile:AfterPendingWrites" ,
5872
+
5873
+ TEST_SYNC_POINT_CALLBACK (" DBImpl::IngestExternalFile:AfterAllowWriteCheck" ,
5885
5874
nullptr );
5886
5875
5887
5876
num_running_ingest_file_ += static_cast <int >(num_cfs);
@@ -6036,9 +6025,11 @@ Status DBImpl::IngestExternalFiles(
6036
6025
}
6037
6026
6038
6027
if (!allow_write) {
6028
+ WriteThread::Writer nonmem_w;
6039
6029
if (two_write_queues_) {
6040
6030
nonmem_write_thread_.ExitUnbatched (&nonmem_w);
6041
6031
}
6032
+ WriteThread::Writer w;
6042
6033
write_thread_.ExitUnbatched (&w);
6043
6034
}
6044
6035
0 commit comments