Skip to content

Commit

Permalink
Add --vt-sev-insert-size
Browse files Browse the repository at this point in the history
  • Loading branch information
mattmundell committed Jun 19, 2023
1 parent d7d6351 commit f6fc2bc
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 15 deletions.
8 changes: 8 additions & 0 deletions src/gvmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1887,6 +1887,7 @@ gvmd (int argc, char** argv, char *env[])
static gchar *feed_lock_path = NULL;
static int feed_lock_timeout = 0;
static int vt_ref_insert_size = VT_REF_INSERT_SIZE_DEFAULT;
static int vt_sev_insert_size = VT_SEV_INSERT_SIZE_DEFAULT;
static gchar *vt_verification_collation = NULL;

GString *full_disable_commands = g_string_new ("");
Expand Down Expand Up @@ -2216,6 +2217,11 @@ gvmd (int argc, char** argv, char *env[])
"Max number of VT refs to insert per statement during VT update,"
" 0 for unlimited, default: "
G_STRINGIFY (VT_REF_INSERT_SIZE_DEFAULT), "<number>" },
{ "vt-sev-insert-size", '\0', 0, G_OPTION_ARG_INT,
&vt_sev_insert_size,
"Max number of VT severities to insert per statement during VT update,"
" 0 for unlimited, default: "
G_STRINGIFY (VT_SEV_INSERT_SIZE_DEFAULT), "<number>" },
{ "vt-verification-collation", '\0', 0, G_OPTION_ARG_STRING,
&vt_verification_collation,
"Set collation for VT verification to <collation>, omit or leave"
Expand Down Expand Up @@ -2305,6 +2311,8 @@ gvmd (int argc, char** argv, char *env[])

set_vt_ref_insert_size (vt_ref_insert_size);

set_vt_sev_insert_size (vt_sev_insert_size);

/* Set VT verification collation override */
set_vt_verification_collation (vt_verification_collation);

Expand Down
35 changes: 20 additions & 15 deletions src/manage_sql_nvts.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,6 @@
*/
#define G_LOG_DOMAIN "md manage"

/**
* @brief Rows per statement when inserting VT refs for update/rebuild.
*
* There are about 500k vt_refs.
*/
#define VT_REFS_BATCH_SIZE 50000

/**
* @brief Rows per statement when inserting VT severities for update/rebuild.
*
* There are about 80k vt_severities.
*/
#define VT_SEVS_BATCH_SIZE 100000


/* Headers from backend specific manage_xxx.c file. */

Expand All @@ -78,6 +64,11 @@ create_tables_nvt (const gchar *);
*/
static int vt_ref_insert_size = VT_REF_INSERT_SIZE_DEFAULT;

/**
* @brief Max number of rows inserted per statement.
*/
static int vt_sev_insert_size = VT_SEV_INSERT_SIZE_DEFAULT;

/**
* @brief File socket for OSP NVT update.
*/
Expand Down Expand Up @@ -155,6 +146,20 @@ set_vt_ref_insert_size (int new_size)
vt_ref_insert_size = new_size;
}

/**
* @brief Set the VT severity insert size.
*
* @param new_size New size.
*/
void
set_vt_sev_insert_size (int new_size)
{
if (new_size < 0)
vt_sev_insert_size = 0;
else
vt_sev_insert_size = new_size;
}

/**
* @brief Ensures the sanity of nvts cache in DB.
*/
Expand Down Expand Up @@ -1766,7 +1771,7 @@ update_nvts_from_vts (element_t *get_vts_response,
sql ("TRUNCATE nvt_preferences;");

vt_refs_batch = batch_start (vt_ref_insert_size);
vt_sevs_batch = batch_start (VT_SEVS_BATCH_SIZE);
vt_sevs_batch = batch_start (vt_sev_insert_size);
vt = element_first_child (vts);
while (vt)
{
Expand Down
10 changes: 10 additions & 0 deletions src/manage_sql_nvts.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,16 @@
void
set_vt_ref_insert_size (int);

/**
* @brief Default for vt_sev_insert_size.
*
* There are about 80k vt_severities.
*/
#define VT_SEV_INSERT_SIZE_DEFAULT 100000

void
set_vt_sev_insert_size (int);

const char *
get_osp_vt_update_socket ();

Expand Down

0 comments on commit f6fc2bc

Please sign in to comment.