caetanosauer / zero

Fork of the Shore-MT storage manager used by the research project Instant Recovery
Other
29 stars 10 forks source link

Concurrency Problem in Archive Index #5

Closed llersch closed 9 years ago

llersch commented 9 years ago

ArchiveIndex has a member: std::vector runs The last element of this vector is the run being generated.

T1: Archiver Thread T2: Writer Thread

// Run 1
T1: assemb.start() //get block
T1: assemb.add(lr)... assemb.add(lr)... assemb.add(lr)...
T1: assemb.finish() ----> newBlock()

// Run 2
T1: assemb.start() //get block
T1: assemb.add(lr)... assemb.add(lr)... assemb.add(lr)...
T2: closeCurrentRun() ----> finishRun() //inserts empty run element to the back of runs (for the new run)

newBlock() inserts an empty block in the run runs.back().

A new run is only inserted in the runs vector after the Writer Thread finished writing the current run to disk. Therefore, the Archiver Thread may start processing log records pertaining to a new run and inserting then to the element runs.back() which refers to the old run (because it was not written to disk yet).

caetanosauer commented 9 years ago

Fixed in 22a0079