Skip to content

Commit 464b7b5

Browse files
committed
exmdb: emit notifications only after SQL transactions are complete
The notification that a new mail object has come into existence was sent out before the sqlite transaction was finished, leading midb to not find the mail. This occurred since gromox-2.30 because that is when we made mailboxes concurrently readable. References: GXL-519, GXL-537, DESK-2301, DESK-2311 References: DESK-2402, DESK-2421, DESK-2436, DESK-2449
1 parent 8f3f0dc commit 464b7b5

File tree

8 files changed

+268
-177
lines changed

8 files changed

+268
-177
lines changed

exch/exmdb/db_engine.cpp

Lines changed: 79 additions & 68 deletions
Large diffs are not rendered by default.

exch/exmdb/db_engine.hpp

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ struct db_conn {
168168
}
169169
};
170170
using ID_ARRAYS = std::map<const char *, std::vector<uint32_t>, xless>;
171+
/* As long as any NOTIFQ object is alive, dbase should be held at least read-locked. */
172+
using NOTIFQ = std::vector<std::pair<DB_NOTIFY_DATAGRAM, ID_ARRAYS>>;
171173

172174
db_conn(db_base &);
173175
~db_conn();
@@ -179,20 +181,20 @@ struct db_conn {
179181
db_base_wr_ptr lock_base_wr();
180182
void update_dynamic(uint64_t folder_id, uint32_t search_flags, const RESTRICTION *prestriction, const LONGLONG_ARRAY *pfolder_ids, db_base &);
181183
void delete_dynamic(uint64_t folder_id, db_base *);
182-
void proc_dynamic_event(cpid_t, enum dynamic_event, uint64_t id1, uint64_t id2, uint64_t id3, db_base &);
183-
void notify_new_mail(uint64_t folder_id, uint64_t msg_id, db_base &);
184-
void notify_message_creation(uint64_t folder_id, uint64_t msg_id, db_base &);
185-
void notify_link_creation(uint64_t parent_id, uint64_t msg_id, db_base &);
186-
void notify_folder_creation(uint64_t parent_id, uint64_t folder_id, const db_base &);
187-
void notify_message_deletion(uint64_t folder_id, uint64_t msg_id, db_base &);
188-
void notify_link_deletion(uint64_t parent_id, uint64_t msg_id, db_base &);
189-
void notify_folder_deletion(uint64_t parent_id, uint64_t folder_id, const db_base &);
190-
void notify_message_modification(uint64_t folder_id, uint64_t msg_id, db_base &);
191-
void notify_folder_modification(uint64_t parent_id, uint64_t folder_id, const db_base &);
192-
void notify_message_movecopy(BOOL b_copy, uint64_t folder_id, uint64_t msg_id, uint64_t old_fid, uint64_t old_mid, db_base &);
193-
void notify_folder_movecopy(BOOL b_copy, uint64_t parent_id, uint64_t folder_id, uint64_t old_pid, uint64_t old_fid, const db_base &);
194-
void notify_cttbl_reload(uint32_t table_id, const db_base &);
195-
void transport_new_mail(uint64_t folder_id, uint64_t msg_id, uint32_t msg_flags, const char *klass, const db_base &);
184+
void proc_dynamic_event(cpid_t, enum dynamic_event, uint64_t id1, uint64_t id2, uint64_t id3, db_base &, NOTIFQ &);
185+
void notify_new_mail(uint64_t folder_id, uint64_t msg_id, db_base &, NOTIFQ &);
186+
void notify_message_creation(uint64_t folder_id, uint64_t msg_id, db_base &, NOTIFQ &);
187+
void notify_link_creation(uint64_t parent_id, uint64_t msg_id, db_base &, NOTIFQ &);
188+
void notify_folder_creation(uint64_t parent_id, uint64_t folder_id, const db_base &, NOTIFQ &);
189+
void notify_message_deletion(uint64_t folder_id, uint64_t msg_id, db_base &, NOTIFQ &);
190+
void notify_link_deletion(uint64_t parent_id, uint64_t msg_id, db_base &, NOTIFQ &);
191+
void notify_folder_deletion(uint64_t parent_id, uint64_t folder_id, const db_base &, NOTIFQ &);
192+
void notify_message_modification(uint64_t folder_id, uint64_t msg_id, db_base &, NOTIFQ &);
193+
void notify_folder_modification(uint64_t parent_id, uint64_t folder_id, const db_base &, NOTIFQ &);
194+
void notify_message_movecopy(BOOL b_copy, uint64_t folder_id, uint64_t msg_id, uint64_t old_fid, uint64_t old_mid, db_base &, NOTIFQ &);
195+
void notify_folder_movecopy(BOOL b_copy, uint64_t parent_id, uint64_t folder_id, uint64_t old_pid, uint64_t old_fid, const db_base &, NOTIFQ &);
196+
void notify_cttbl_reload(uint32_t table_id, const db_base &, NOTIFQ &);
197+
void transport_new_mail(uint64_t folder_id, uint64_t msg_id, uint32_t msg_flags, const char *klass, const db_base &, NOTIFQ &);
196198
void begin_batch_mode(db_base &);
197199
/* pdb will also be put */
198200
static void commit_batch_mode_release(std::optional<db_conn> &&pdb, db_base_wr_ptr &&base);
@@ -221,6 +223,7 @@ extern BOOL db_engine_vacuum(const char *path);
221223
BOOL db_engine_unload_db(const char *path);
222224
extern BOOL db_engine_enqueue_populating_criteria(const char *dir, cpid_t, uint64_t folder_id, BOOL recursive, const RESTRICTION *, const LONGLONG_ARRAY *folder_ids);
223225
extern bool db_engine_check_populating(const char *dir, uint64_t folder_id);
226+
extern void dg_notify(db_conn::NOTIFQ &&);
224227

225228
extern unsigned int g_exmdb_schema_upgrades, g_exmdb_search_pacing;
226229
extern unsigned long long g_exmdb_search_pacing_time, g_exmdb_lock_timeout;

0 commit comments

Comments
 (0)