Sink tests can crash because test cleanup runs while queries are still active
Open, NormalPublic

Description

Sink::Store::removeDataFromDisk is run while queries are still running. The query then ends up crashing when e.g. executeInitialQuery finishes, resulting in destruction of EntityStore and the corresponding transaction, triggering the following assert:
QFATAL : QueryTest::testIncrementalWithFetchMore() ASSERT: "sEnvironments.values().contains(d->env)" in file /src/sink/common/storage_lmdb.cpp, line 755

Not very high prio because this is not usually reproducible except in tests.

Thread 2 (Thread 0x7fffe74b4700 (LWP 3101)):                                                                                                
#0  0x00007ffff44cc660 in raise () from /lib64/libc.so.6                                                                                                
#1  0x00007ffff44cdc41 in abort () from /lib64/libc.so.6                                                                       
#2  0x00007ffff51c9657 in QMessageLogger::fatal(char const*, ...) const () from /lib64/libQt5Core.so.5                                                         
#3  0x00007ffff51c4c66 in qt_assert(char const*, char const*, int) () from /lib64/libQt5Core.so.5                                                              #4  0x00007ffff6ff5b2c in Sink::Storage::DataStore::Transaction::commit(std::function<void (Sink::Storage::DataStore::Error const&)> const&) (this=0x6d23f8,
    errorHandler=...) at /src/sink/common/storage_lmdb.cpp:755                                                                                          
#5  0x00007ffff6ff59ef in Sink::Storage::DataStore::Transaction::~Transaction (this=0x6d23f8) at /src/sink/common/storage_lmdb.cpp:734 
#6  0x00007ffff6fdcf43 in Sink::Storage::EntityStore::Private::~Private (this=0x6d23d0) at /src/sink/common/storage/entitystore.cpp:97                         #7  0x00007ffff6fdceea in QtSharedPointer::CustomDeleter<Sink::Storage::EntityStore::Private, QtSharedPointer::NormalDeleter>::execute (this=0x7fffe000c700) 
    at /usr/include/qt5/QtCore/qsharedpointer_impl.h:195                                    
#8  0x00007ffff6fdce21 in QtSharedPointer::ExternalRefCountWithCustomDeleter<Sink::Storage::EntityStore::Private, QtSharedPointer::NormalDeleter>::deleter (       self=0x7fffe000c6f0) at /usr/include/qt5/QtCore/qsharedpointer_impl.h:213                                                          
#9  0x0000000000470d0b in QtSharedPointer::ExternalRefCountData::destroy (this=0x7fffe000c6f0) at /usr/include/qt5/QtCore/qsharedpointer_impl.h:157
#10 0x00007ffff6e3a4bd in QSharedPointer<Sink::Storage::EntityStore::Private>::deref (dd=0x7fffe000c6f0) at /usr/include/qt5/QtCore/qsharedpointer_impl.h:461
#11 0x00007ffff6e3a479 in QSharedPointer<Sink::Storage::EntityStore::Private>::deref (this=0x7fffe74b39e0)
    at /usr/include/qt5/QtCore/qsharedpointer_impl.h:456                                                 
#12 0x00007ffff6e3a455 in QSharedPointer<Sink::Storage::EntityStore::Private>::~QSharedPointer (this=0x7fffe74b39e0)             
    at /usr/include/qt5/QtCore/qsharedpointer_impl.h:313                                                   
#13 0x00007ffff6e3a1b5 in Sink::Storage::EntityStore::~EntityStore (this=0x7fffe74b39e0) at /src/sink/common/storage/entitystore.h:40
#14 0x00007ffff6e9da19 in QueryWorker<Sink::ApplicationDomain::Folder>::executeInitialQuery (this=0x7fffe74b3ab8, query=..., resultProvider=..., batchsize=0,
    state=...) at /src/sink/common/queryrunner.cpp:355                                                                                      
#15 0x00007ffff6ed7edb in QueryRunner<Sink::ApplicationDomain::Folder>::fetch(Sink::Query const&, QByteArray const&)::{lambda()#1}::operator()() const (
    this=0x6d2f30) at /src/sink/common/queryrunner.cpp:135                                                                     
#16 0x00007ffff6ed7b1f in std::_Function_handler<ReplayResult (), QueryRunner<Sink::ApplicationDomain::Folder>::fetch(Sink::Query const&, QByteArray const&)::{
lambda()#1}>::_M_invoke(std::_Any_data const&) (__functor=...) at /usr/bin/../lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/bits/std_function.h:301  
#17 0x00007ffff6eba4fd in std::function<ReplayResult ()>::operator()() const (this=0x6d3e48)                                                                
    at /usr/bin/../lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/bits/std_function.h:706                                            
#18 0x00007ffff6eb95da in QtConcurrent::StoredFunctorCall0<ReplayResult, std::function<ReplayResult ()> >::runFunctor() (this=0x6d3e00)
    at /usr/include/qt5/QtConcurrent/qtconcurrentstoredfunctioncall.h:60                                                                                       
#19 0x00007ffff6eb94a1 in QtConcurrent::RunFunctionTask<ReplayResult>::run (this=0x6d3e00) at /usr/include/qt5/QtConcurrent/qtconcurrentrunbase.h:108          #20 0x00007ffff51d8b71 in QThreadPoolThread::run() () from /lib64/libQt5Core.so.5                                                                            
#21 0x00007ffff51dbde2 in QThreadPrivate::start(void*) () from /lib64/libQt5Core.so.5                                                                          
#22 0x00007ffff428150b in start_thread () from /lib64/libpthread.so.0                                                            
#23 0x00007ffff458d16f in clone () from /lib64/libc.so.6
cmollekopf triaged this task as Normal priority.