[Date Prev][Date Next] [Chronological] [Thread] [Top]

(ITS#8209) Broken MDB_CP_COMPACT threading



Full_Name: Hallvard B Furuseth
Version: LMDB_0.9.15
OS: 
URL: ftp://ftp.openldap.org/incoming/
Submission from: (NULL) (81.191.45.5)
Submitted by: hallvard


mdb_env_copyfd1() and mdb_env_copythr() synchronize via my->mc_new,
but incorrectly.

copythr() starts before there is any data to consume, and copyfd1()
does not tell it (by setting mc_new and signalling) when there is
data.  Instead it sets mc_new before it has finished producing the
data.  I suppose copythr just waits for a spurious wakeup, I haven't
looked closely.  It got it right originally when copyfd1 did not start
the new thread until data (metapages) was ready.  Or copyfd1 could
start with mc_new = 0, and set it and signal when data is ready.

copythr holds the mutex while writing.  That's not how conds are
supposed to be used.  Threads are supposed to grab the mutex briefly
around code which operates on mc_new.

mc_status can be lost.  Copyfd1 does not always use it, or it discards
it.  And copythr should set mc_new=0 before exiting also when setting
mc_status. so copyfd1 won't just sit and wait.