we have a similar issue which is effecting our site. Our site is large and we use bp_docs extensively within a number of groups.
We have discovered that when we add a featured image to a post and submit the post we get an 'error establishing database connection' for around 20-40 mins.
Our IT department has indicated that this is due to "multiple apache worker processes are created when trying to set the featured image".
We worked extensively to identify the issue, initially we believed the theme to be at fault but we have ruled that out by a process of elimination.
By disabling and re-enabling plugins and re-running the process of setting a featured image we have determined that 'buddypress docs' is somehow putting enough of a strain on the system to take it down.
Here are some log entries (edited to remove certain references) that have occurred around the time of the system going down, BP_docs and bp_docs are mentioned a lot:
[error] [client ***.***.***.***] PHP Warning: in_array() expects parameter 2 to be array, null given in /var/www/wp-content/plugins/buddypress-docs/includes/integration-groups.php on line 264
Above repeated multiple times (~20)
[error] [client ***.***.***.***] WordPress database error Lost connection to MySQL server during query for query SELECT option_value FROM wp_options WHERE option_name = 'bp-docs-enable-attachments' LIMIT 1 made by require_once('wp-admin/admin.php'), require_once('wp-load.php'), require_once('wp-config.php'), require_once('wp-settings.php'), do_action('plugins_loaded'), call_user_func_array, BP_Docs->load_hook, do_action('bp_docs_load'), call_user_func_array, BP_Docs->do_integration, BP_Docs_Component->__construct, BP_Docs_Component->setup_hooks, BP_Docs_Attachments->__construct, bp_docs_enable_attachments, get_option, referer: https://***/wp-admin/post.php?post=583&action=edit
[error] [client ***.***.***.***] WordPress database error Lost connection to MySQL server during query for query SELECT post_id, meta_key, meta_value FROM wp_postmeta WHERE post_id IN (1569) ORDER BY meta_id ASC made by require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/buddy-2014-01/page.php'), the_content, apply_filters('the_content'), call_user_func_array, bp_replace_the_content, apply_filters('bp_replace_the_content'), call_user_func_array, BP_Docs_Theme_Compat->single_content, bp_buffer_template_part, bp_get_template_part, bp_locate_template, load_template, require('/plugins/buddypress-docs/includes/templates/docs/single/index.php'), include('/plugins/buddypress-docs/includes/templates/docs/single/attachments.php'), bp_docs_attachment_item_markup, bp_docs_get_attachment_url, get_attached_file, get_post_meta, get_metadata, update_meta_cache, referer: https://***/wp-admin/post.php?post=583&action=edit
Above repeated multiple times
[error] [client ***.***.***.***] WordPress database error Lost connection to MySQL server during query for query SELECT wp_posts.* FROM wp_posts WHERE 1=1 AND ( wp_posts.ID NOT IN (\n\t\t\t\t\tSELECT object_id\n\t\t\t\t\tFROM wp_term_relationships\n\t\t\t\t\tWHERE term_taxonomy_id IN (39)\n\t\t\t\t) ) AND wp_posts.post_type = 'bp_doc' AND ((wp_posts.post_status = 'publish')) GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC made by require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/buddy-2014-01/homepage.php'), get_footer, locate_template, load_template, require_once('/themes/buddy-2014-01/footer.php'), dynamic_sidebar, call_user_func_array, WP_Widget->display_callback, WP_Widget_Recent_Posts->widget, WP_Query->__construct, WP_Query->query, WP_Query->get_posts, do_action_ref_array, call_user_func_array, bp_docs_general_access_protection, BP_Docs_Access_Query->get_doc_ids, get_posts, WP_Query->query, WP_Query->get_posts
We have a large user base (20,000+ members) but far fewer concurrent users (typically 20-50). The system running wordpress is designed for robust usage and should theoretically be taken out by one active user posting a featured image to a blog post.
I hope this helps in some way. Please let me know if we can provide any further material to help rectify the problem. It should be noted that when we activate/deactivate the plugin there is general very notable change in site responsiveness.
Good luck finding a solution, full list of plugins used is available below.