Skip to content

Commit

Permalink
skip removing entries from sqlite if store-queue-on-shutdown is used
Browse files Browse the repository at this point in the history
if `--store-queue-on-shutdown` is used, database should only be accessed during
shutdown and on initial startup. Skipping the done() saves the unnecessary query
preparation, database locks, etc...

 - fixes #369
  • Loading branch information
sni committed Jun 14, 2023
1 parent 4426067 commit ced0d3a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions libgearman-server/plugins/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ class Context {
_store_on_shutdown= store_on_shutdown_;
}

bool is_store_on_shutdown()
{
return _store_on_shutdown;
}

bool has_error()
{
return _error_string.size();
Expand Down
3 changes: 3 additions & 0 deletions libgearman-server/plugins/queue/sqlite/instance.cc
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,9 @@ gearmand_error_t Instance::done(gearman_server_st*,
const char *function_name,
size_t function_name_size)
{
if (is_store_on_shutdown())
return GEARMAND_SUCCESS;

gearmand_log_debug(GEARMAN_DEFAULT_LOG_PARAM,
"sqlite done: unique_key: %.*s, function_name: %.*s",
int(unique_size), (char*)unique,
Expand Down

0 comments on commit ced0d3a

Please sign in to comment.