Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bbinc/comdb2_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ enum comdb2_plugin_type {
COMDB2_PLUGIN_QUEUE_CONSUMER,
COMDB2_PLUGIN_QUERY_PREPARER,
COMDB2_PLUGIN_SYSTABLE,
COMDB2_PLUGIN_TRANSACTION_NOTIFIER,
COMDB2_PLUGIN_LAST
};

Expand Down
13 changes: 13 additions & 0 deletions bbinc/transaction_notifier.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#ifndef INCLUDED_TRANSACTION_NOTIFIER_H
#define INCLUDED_TRANSACTION_NOTIFIER_H

#include "list.h"

typedef struct transaction_notifier {
void (*simple_notify)(void);
LINKC_T(struct transaction_notifier) lnk;
} transaction_notifier;

typedef LISTC_T(struct transaction_notifier) transaction_notifier_list;

#endif
4 changes: 4 additions & 0 deletions db/comdb2.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ typedef long long tranid_t;
#include "shard_range.h"
#include "tunables.h"
#include "comdb2_plugin.h"
#include "transaction_notifier.h"

#ifndef LUASP
#include <mem_uncategorized.h>
Expand Down Expand Up @@ -3772,4 +3773,7 @@ void get_client_origin(char *out, size_t outlen, struct sqlclntstate *clnt);
void log_legacy_request(struct ireq *iq, struct sqlclntstate *clnt);
extern void (*gbl_tagged_request_callback)(struct ireq *iq);

extern pthread_mutex_t transaction_notifier_lock;
extern transaction_notifier_list transaction_notifiers;

#endif /* !INCLUDED_COMDB2_H */
7 changes: 7 additions & 0 deletions db/plugin_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,13 @@ static int install_plugin_int(comdb2_plugin_t *new_plugin)
queue_consumer_handlers[consumer_info->type] = consumer_info;
break;
}
case COMDB2_PLUGIN_TRANSACTION_NOTIFIER: {
transaction_notifier *n = (transaction_notifier *)new_plugin->data;
Pthread_mutex_lock(&transaction_notifier_lock);
listc_abl(&transaction_notifiers, n);
Pthread_mutex_unlock(&transaction_notifier_lock);
break;
};
case COMDB2_PLUGIN_INITIALIZER:
break;
case COMDB2_PLUGIN_QUERY_PREPARER: {
Expand Down
11 changes: 11 additions & 0 deletions db/toblock.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ static int block_state_offset_from_ptr(block_state_t *p_blkstate,
int gbl_blockop_count_xrefs[BLOCK_MAXOPCODE];
const char *gbl_blockop_name_xrefs[NUM_BLOCKOP_OPCODES];

pthread_mutex_t transaction_notifier_lock = PTHREAD_MUTEX_INITIALIZER;
transaction_notifier_list transaction_notifiers = {
.top = NULL, .bot = NULL, .count = 0, .diff = offsetof(struct transaction_notifier, lnk)};

static int block2_qadd(struct ireq *iq, block_state_t *p_blkstate, void *trans,
struct packedreq_qadd *buf, blob_buffer_t *blobs)
{
Expand Down Expand Up @@ -6401,6 +6405,13 @@ static int toblock_main(struct javasp_trans_state *javasp_trans_handle, struct i
if (rc == 0) {
osql_postcommit_handle(iq);
handle_postcommit_bpfunc(iq);
struct transaction_notifier *n;
Pthread_mutex_lock(&transaction_notifier_lock);
LISTC_FOR_EACH(&transaction_notifiers, n, lnk)
{
n->simple_notify();
}
Pthread_mutex_unlock(&transaction_notifier_lock);
} else {
osql_postabort_handle(iq);
handle_postabort_bpfunc(iq);
Expand Down