File tree 2 files changed +37
-13
lines changed
2 files changed +37
-13
lines changed Original file line number Diff line number Diff line change @@ -2037,11 +2037,33 @@ void IResearchView::registerFlushCallback() {
2037
2037
return ;
2038
2038
}
2039
2039
2040
- flush->registerCallback (this , [this ]() noexcept {
2041
- return IResearchView::FlushTransactionPtr (
2042
- this ,
2043
- [](arangodb::FlushTransaction*){} // empty deleter
2040
+ auto viewSelf = self ();
2041
+
2042
+ flush->registerCallback (this , [viewSelf]() noexcept {
2043
+ static struct NoopFlushTransaction : arangodb::FlushTransaction {
2044
+ NoopFlushTransaction (): FlushTransaction(" ArangoSearchNoop" ) {}
2045
+ virtual arangodb::Result commit () override {
2046
+ return arangodb::Result (TRI_ERROR_ARANGO_DATA_SOURCE_NOT_FOUND);
2047
+ }
2048
+ } noopFlushTransaction;
2049
+ SCOPED_LOCK_NAMED (viewSelf->mutex (), lock);
2050
+
2051
+ if (!*viewSelf) {
2052
+ return arangodb::FlushFeature::FlushTransactionPtr (
2053
+ &noopFlushTransaction, [](arangodb::FlushTransaction*)->void {}
2054
+ );
2055
+ }
2056
+
2057
+ auto trx = arangodb::FlushFeature::FlushTransactionPtr (
2058
+ viewSelf->get (),
2059
+ [](arangodb::FlushTransaction* trx)->void {
2060
+ ADOPT_SCOPED_LOCK_NAMED (static_cast <IResearchView*>(trx)->self ()->mutex (), lock);
2061
+ }
2044
2062
);
2063
+
2064
+ lock.release (); // unlocked in distructor above
2065
+
2066
+ return trx;
2045
2067
});
2046
2068
2047
2069
// noexcept
Original file line number Diff line number Diff line change @@ -154,15 +154,17 @@ bool FlushFeature::unregisterCallback(void* ptr) {
154
154
void FlushFeature::executeCallbacks () {
155
155
std::vector<FlushTransactionPtr> transactions;
156
156
157
- READ_LOCKER (locker, _callbacksLock);
158
- transactions.reserve (_callbacks.size ());
159
-
160
- // execute all callbacks. this will create as many transactions as
161
- // there are callbacks
162
- for (auto const & cb : _callbacks) {
163
- // copy elision, std::move(..) not required
164
- LOG_TOPIC (TRACE, arangodb::Logger::FLUSH) << " executing flush callback" ;
165
- transactions.emplace_back (cb.second ());
157
+ {
158
+ READ_LOCKER (locker, _callbacksLock);
159
+ transactions.reserve (_callbacks.size ());
160
+
161
+ // execute all callbacks. this will create as many transactions as
162
+ // there are callbacks
163
+ for (auto const & cb: _callbacks) {
164
+ // copy elision, std::move(..) not required
165
+ LOG_TOPIC (TRACE, arangodb::Logger::FLUSH) << " executing flush callback" ;
166
+ transactions.emplace_back (cb.second ());
167
+ }
166
168
}
167
169
168
170
// TODO: make sure all data is synced
You can’t perform that action at this time.
0 commit comments