0

I am using CiviCRM 5.71.1 with WordPRess 6.4.3, but this issue has been going on for a long time and I am, as they say, "at Witt's end" (yes, that spelling :-)

When I try to send a scheduled mailing, it fails to complete and I get a long error in the log which I am sorry to have to burden you with below. Note that I had to truncate the error message in order to comply with the 30K character limit here. Can anyone please tell me how to fix this issue? Thanks.

[error] 
$Fatal Error Details = array:3 [
  "message" => "DB Error: no database selected"
  "code" => null
  "exception" => Civi\Core\Exception\DBQueryException {#3918
    #message: "DB Error: no database selected"
    #code: 0
    #file: "/home/REDACTED/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Error.php"
    #line: 971
    #cause: DB_Error {#3857
      +error_message_prefix: ""
      +mode: 16
      +level: 1024
      +code: -14
      +message: "DB Error: no database selected"
      +userinfo: "INSERT INTO `civicrm_job_log` (`domain_id` , `job_id` , `name` , `command` , `description` , `data` ) VALUES ( 1 ,  2 , 'Send Scheduled Mailings' , 'Entity: Job Action: process_mailing' , 'Finished execution of Send Scheduled Mailings with result: Failure, Error message: DB Error: no database selected' , '\n\nParameters parsed (and passed to API method): \na:1:{s:7:\"version\";i:3;}\n\nFull message: \nFinished execution of Send Scheduled Mailings with result: Failure, Error message: DB Error: no database selected' )  [nativecode=2006 ** MySQL server has gone away]"
      +backtrace: array:30 [
        0 => array:6 [
          "file" => "/home/REDACTED/public_html/wp-content/plugins/civicrm/civicrm/vendor/pear/db/DB.php"
          "line" => 1001
          "function" => "__construct"
          "class" => "PEAR_Error"
          "type" => "->"
          "args" => array:5 [
            0 => "DB Error: no database selected"
            1 => -14
            2 => 16
            3 => array:2 [
              0 => "CRM_Core_Error"
              1 => "exceptionHandler"
            ]
            4 => "INSERT INTO `civicrm_job_log` (`domain_id` , `job_id` , `name` , `command` , `description` , `data` ) VALUES ( 1 ,  2 , 'Send Scheduled Mailings' , 'Entity: Job Action: process_mailing' , 'Finished execution of Send Scheduled Mailings with result: Failure, Error message: DB Error: no database selected' , '\n\nParameters parsed (and passed to API method): \na:1:{s:7:\"version\";i:3;}\n\nFull message: \nFinished execution of Send Scheduled Mailings with result: Failure, Error message: DB Error: no database selected' )  [nativecode=2006 ** MySQL server has gone away]"
          ]
        ]
        1 => array:7 [
          "file" => "/home/REDACTED/public_html/wp-content/plugins/civicrm/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php"
          "line" => 575
          "function" => "__construct"
          "class" => "DB_Error"
          "object" => DB_Error {#3857}
          "type" => "->"
          "args" => array:4 [
            0 => -14
            1 => 16
            2 => array:2 [
              0 => "CRM_Core_Error"
              1 => "exceptionHandler"
            ]
            3 => "INSERT INTO `civicrm_job_log` (`domain_id` , `job_id` , `name` , `command` , `description` , `data` ) VALUES ( 1 ,  2 , 'Send Scheduled Mailings' , 'Entity: Job Action: process_mailing' , 'Finished execution of Send Scheduled Mailings with result: Failure, Error message: DB Error: no database selected' , '\n\nParameters parsed (and passed to API method): \na:1:{s:7:\"version\";i:3;}\n\nFull message: \nFinished execution of Send Scheduled Mailings with result: Failure, Error message: DB Error: no database selected' )  [nativecode=2006 ** MySQL server has gone away]"
          ]
        ]
        2 => array:6 [
          "file" => "/home/REDACTED/public_html/wp-content/plugins/civicrm/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php"
          "line" => 223
          "function" => "_raiseError"
          "class" => "PEAR"
          "type" => "::"
          "args" => array:8 [
            0 => DB_mysqli {#1284
              +_debug: false
              +_default_error_mode: null
              +_default_error_options: null
              +_default_error_handler: ""
              +_error_class: "DB_Error"
              +_expected_errors: []
              +fetchmode: 1
              +fetchmode_object_class: "stdClass"
              +was_connected: null
              +last_query: "INSERT INTO `civicrm_job_log` (`domain_id` , `job_id` , `name` , `command` , `description` , `data` ) VALUES ( 1 ,  2 , 'Send Scheduled Mailings' , 'Entity: Job Action: process_mailing' , 'Finished execution of Send Scheduled Mailings with result: Failure, Error message: DB Error: no database selected' , '\n\nParameters parsed (and passed to API method): \na:1:{s:7:\"version\";i:3;}\n\nFull message: \nFinished execution of Send Scheduled Mailings with result: Failure, Error message: DB Error: no database selected' ) "
              +options: array:8 [
                "result_buffering" => 500
                "persistent" => false
                "ssl" => false
                "debug" => 0
                "seqname_format" => "%s_seq"
                "autofree" => false
                "portability" => 0
                "optimize" => "performance"
              ]
              +last_parameters: []
              +prepare_tokens: []
              +prepare_types: []
              +prepared_queries: []
              +_last_query_manip: true
              +_next_query_manip: false
              +phptype: "mysqli"
              +dbsyntax: "mysqli"
              +features: array:7 [
                "limit" => "alter"
                "new_link" => false
                "numrows" => true
                "pconnect" => false
                "prepare" => false
                "ssl" => true
                "transactions" => true
              ]
              +errorcode_map: array:29 [
                1004 => -15
                1005 => -15
                1006 => -15
                1007 => -5
                1008 => -17
                1022 => -5
                1044 => -26
                1046 => -14
                1048 => -3
                1049 => -27
                1050 => -5
                1051 => -18
                1054 => -19
                1061 => -5
                1062 => -5
                1064 => -2
                1091 => -4
                1100 => -21
                1136 => -22
                1142 => -26
                1146 => -18
                1205 => -30
                1213 => -31
                1216 => -3
                1217 => -3
                1356 => "-32"
                1365 => -13
                1451 => -3
                1452 => -3
              ]
              +connection: mysqli {#1285}
              +dsn: array:10 [
                "phptype" => "mysqli"
                "dbsyntax" => "mysqli"
                "username" => "REDACTED_REDACTED"
                "password" => "REDACTED"
                "protocol" => "tcp"
                "hostspec" => "localhost"
                "port" => false
                "socket" => false
                "database" => "REDACTED_REDACTED"
                "new_link" => "true"
              ]
              +autocommit: true
              +transaction_opcount: 0
              +_db: "REDACTED_REDACTED"
              +mysqli_flags: array:11 [
                1 => "not_null"
                2 => "primary_key"
                4 => "unique_key"
                8 => "multiple_key"
                16 => "blob"
                32 => "unsigned"
                64 => "zerofill"
                512 => "auto_increment"
                1024 => "timestamp"
                2048 => "set"
                32768 => "group_by"
              ]
              +mysqli_types: array:25 [
                0 => "decimal"
                1 => "tinyint"
                2 => "int"
                3 => "int"
                4 => "float"
                5 => "double"
                7 => "timestamp"
                8 => "bigint"
                9 => "mediumint"
                10 => "date"
                11 => "time"
                12 => "datetime"
                13 => "year"
                14 => "date"
                247 => "enum"
                248 => "set"
                249 => "tinyblob"
                250 => "mediumblob"
                251 => "longblob"
                252 => "blob"
                253 => "varchar"
                254 => "char"
                255 => "geometry"
                16 => "bit"
                246 => "decimal"
              ]
            }
            1 => null
            2 => -14
            3 => 16
            4 => array:2 [
              0 => "CRM_Core_Error"
              1 => "exceptionHandler"
            ]
            5 => "INSERT INTO `civicrm_job_log` (`domain_id` , `job_id` , `name` , `command` , `description` , `data` ) VALUES ( 1 ,  2 , 'Send Scheduled Mailings' , 'Entity: Job Action: process_mailing' , 'Finished execution of Send Scheduled Mailings with result: Failure, Error message: DB Error: no database selected' , '\n\nParameters parsed (and passed to API method): \na:1:{s:7:\"version\";i:3;}\n\nFull message: \nFinished execution of Send Scheduled Mailings with result: Failure, Error message: DB Error: no database selected' )  [nativecode=2006 ** MySQL server has gone away]"
            6 => "DB_Error"
            7 => true
          ]
        ]
        3 => array:7 [
          "file" => "/home/REDACTED/public_html/wp-content/plugins/civicrm/civicrm/vendor/pear/db/DB/common.php"
          "line" => 1952
          "function" => "__call"
          "class" => "PEAR"
          "object" => DB_mysqli {#1284}
          "type" => "->"
          "args" => array:2 [
            0 => "raiseError"
            1 => array:7 [
              0 => null
              1 => -14
              2 => null
              3 => null
              4 => "INSERT INTO `civicrm_job_log` (`domain_id` , `job_id` , `name` , `command` , `description` , `data` ) VALUES ( 1 ,  2 , 'Send Scheduled Mailings' , 'Entity: Job Action: process_mailing' , 'Finished execution of Send Scheduled Mailings with result: Failure, Error message: DB Error: no database selected' , '\n\nParameters parsed (and passed to API method): \na:1:{s:7:\"version\";i:3;}\n\nFull message: \nFinished execution of Send Scheduled Mailings with result: Failure, Error message: DB Error: no database selected' )  [nativecode=2006 ** MySQL server has gone away]"
              5 => "DB_Error"
              6 => true
            ]
          ]
        ]
        4 => array:7 [
          "file" => "/home/REDACTED/public_html/wp-content/plugins/civicrm/civicrm/vendor/pear/db/DB/mysqli.php"
          "line" => 966
          "function" => "raiseError"
          "class" => "DB_common"
          "object" => DB_mysqli {#1284}
          "type" => "->"
          "args" => array:5 [
            0 => -14
            1 => null
            2 => null
            3 => "INSERT INTO `civicrm_job_log` (`domain_id` , `job_id` , `name` , `command` , `description` , `data` ) VALUES ( 1 ,  2 , 'Send Scheduled Mailings' , 'Entity: Job Action: process_mailing' , 'Finished execution of Send Scheduled Mailings with result: Failure, Error message: DB Error: no database selected' , '\n\nParameters parsed (and passed to API method): \na:1:{s:7:\"version\";i:3;}\n\nFull message: \nFinished execution of Send Scheduled Mailings with result: Failure, Error message: DB Error: no database selected' )  [nativecode=2006 ** MySQL server has gone away]"
            4 => "2006 ** MySQL server has gone away"
          ]
        ]
        5 => array:7 [
          "file" => "/home/REDACTED/public_html/wp-content/plugins/civicrm/civicrm/vendor/pear/db/DB/mysqli.php"
          "line" => 398
          "function" => "mysqliRaiseError"
          "class" => "DB_mysqli"
          "object" => DB_mysqli {#1284}
          "type" => "->"
          "args" => array:1 [
            0 => -14
          ]
        ]
        6 => array:7 [
          "file" => "/home/REDACTED/public_html/wp-content/plugins/civicrm/civicrm/vendor/pear/db/DB/common.php"
          "line" => 1241
          "function" => "simpleQuery"
          "class" => "DB_mysqli"
          "object" => DB_mysqli {#1284}
          "type" => "->"
          "args" => array:1 [
            0 => "INSERT INTO `civicrm_job_log` (`domain_id` , `job_id` , `name` , `command` , `description` , `data` ) VALUES ( 1 ,  2 , 'Send Scheduled Mailings' , 'Entity: Job Action: process_mailing' , 'Finished execution of Send Scheduled Mailings with result: Failure, Error message: DB Error: no database selected' , '\n\nParameters parsed (and passed to API method): \na:1:{s:7:\"version\";i:3;}\n\nFull message: \nFinished execution of Send Scheduled Mailings with result: Failure, Error message: DB Error: no database selected' ) "
          ]
        ]
        7 => array:7 [
          "file" => "/home/REDACTED/public_html/wp-content/plugins/civicrm/civicrm/packages/DB/DataObject.php"
          "line" => 2696
          "function" => "query"
          "class" => "DB_common"
          "object" => DB_mysqli {#1284}
          "type" => "->"
          "args" => array:1 [
            0 => "INSERT INTO `civicrm_job_log` (`domain_id` , `job_id` , `name` , `command` , `description` , `data` ) VALUES ( 1 ,  2 , 'Send Scheduled Mailings' , 'Entity: Job Action: process_mailing' , 'Finished execution of Send Scheduled Mailings with result: Failure, Error message: DB Error: no database selected' , '\n\nParameters parsed (and passed to API method): \na:1:{s:7:\"version\";i:3;}\n\nFull message: \nFinished execution of Send Scheduled Mailings with result: Failure, Error message: DB Error: no database selected' ) "
          ]
        ]
        8 => array:7 [
          "file" => "/home/REDACTED/public_html/wp-content/plugins/civicrm/civicrm/packages/DB/DataObject.php"
          "line" => 1245
          "function" => "_query"
          "class" => "DB_DataObject"
          "object" => CRM_Core_DAO_JobLog {#3832
            +_DB_DataObject_version: "1.11.3"
            +__table: "civicrm_job_log"
            +N: 0
            +_database_dsn: ""
            +_database_dsn_md5: "8b8d93655162a3012db382eebbf95622"
            +_database: "REDACTED_REDACTED"
            +_query: array:11 [
              "condition" => ""
              "group_by" => ""
              "order_by" => ""
              "having" => ""
              "useindex" => ""
              "limit_start" => ""
              "limit_count" => ""
              "data_select" => "*"
              "unions" => []
              "derive_table" => ""
              "derive_select" => ""
            ]
            +_DB_resultid: null
            +_resultFields: false
            +_link_loaded: false
            +_join: ""
            +_lastError: false
            #resultCopies: 0
            #_options: []
            +id: null
            +domain_id: 1
            +run_time: null
            +job_id: "2"
            +name: "Send Scheduled Mailings"
            +command: "Entity: Job Action: process_mailing"
            +description: "Finished execution of Send Scheduled Mailings with result: Failure, Error message: DB Error: no database selected"
            +data: """
              \n
              \n
              Parameters parsed (and passed to API method): \n
              a:1:{s:7:"version";i:3;}\n
              \n
              Full message: \n
              Finished execution of Send Scheduled Mailings with result: Failure, Error message: DB Error: no database selected
              """
          }
          "type" => "->"
          "args" => array:1 [
            0 => "INSERT INTO `civicrm_job_log` (`domain_id` , `job_id` , `name` , `command` , `description` , `data` ) VALUES ( 1 ,  2 , 'Send Scheduled Mailings' , 'Entity: Job Action: process_mailing' , 'Finished execution of Send Scheduled Mailings with result: Failure, Error message: DB Error: no database selected' , '\n\nParameters parsed (and passed to API method): \na:1:{s:7:\"version\";i:3;}\n\nFull message: \nFinished execution of Send Scheduled Mailings with result: Failure, Error message: DB Error: no database selected' ) "
          ]
        ]
        9 => array:7 [
          "file" => "/home/REDACTED/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/DAO.php"
          "line" => 738
          "function" => "insert"
          "class" => "DB_DataObject"
          "object" => CRM_Core_DAO_JobLog {#3832}
          "type" => "->"
          "args" => []
        ]
        10 => array:7 [
          "file" => "/home/REDACTED/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/JobManager.php"
          "line" => 247
          "function" => "save"
          "class" => "CRM_Core_DAO"
          "object" => CRM_Core_DAO_JobLog {#3832}
          "type" => "->"
          "args" => []
        ]
        11 => array:7 [
          "file" => "/home/REDACTED/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/JobManager.php"
          "line" => 132
          "function" => "logEntry"
          "class" => "CRM_Core_JobManager"
          "object" => CRM_Core_JobManager {#3285
            +jobs: array:27 [
              25 => CRM_Core_ScheduledJob {#3275
                +id: "25"
                +domain_id: "1"
                +run_frequency: "Hourly"
                +last_run: "2024-03-31 16:00:11"
                +scheduled_run_date: null
                +name: "Call SumFields.Gendata API"
                +description: "Call SumFields.Gendata API"
                +api_entity: "SumFields"
                +api_action: "Gendata"
                +parameters: null
                +is_active: "1"
                +action: null
                +class: null
                +apiParams: array:1 [
                  "version" => 3
                ]
                +remarks: []
              }
              1 => CRM_Core_ScheduledJob {#3276
                +id: "1"
                +domain_id: "1"
                +run_frequency: "Daily"
                +last_run: "2024-03-31 02:00:09"
                +scheduled_run_date: null
                +name: "CiviCRM Update Check"
                +description: "Checks for CiviCRM version updates. Important for keeping the database secure. Also sends anonymous usage statistics to civicrm.org to to assist in prioritizing ongoing development efforts."
                +api_entity: "Job"
                +api_action: "version_check"
                +parameters: null
                +is_active: "1"
                +action: null
                +class: null
                +apiParams: array:1 [
                  "version" => 3
                ]
                +remarks: []
              }
              19 => CRM_Core_ScheduledJob {#3277
                +id: "19"
                +domain_id: "1"
                +run_frequency: "Always"
                +last_run: "2024-03-31 16:00:12"
                +scheduled_run_date: null
                +name: "Civirules cron"
                +description: "Trigger civirules cron triggers"
                +api_entity: "Civirules"
                +api_action: "Cron"
                +parameters: null
                +is_active: "1"
                +action: null
                +class: null
                +apiParams: array:1 [
                  "version" => 3
                ]
                +remarks: []
              }
              13 => CRM_Core_ScheduledJob {#3278
                +id: "13"
                +domain_id: "1"
                +run_frequency: "Hourly"
                +last_run: null
                +scheduled_run_date: null
                +name: "Clean-up Temporary Data and Files"
                +description: "Removes temporary data and files, and clears old data from cache tables. Recommend running this job every hour to help prevent database and file system bloat."
                +api_entity: "Job"
                +api_action: "cleanup"
                +parameters: null
                +is_active: "0"
                +action: null
                +class: null
                +apiParams: array:1 [
                  "version" => 3
                ]
                +remarks: []
              }
              16 => CRM_Core_ScheduledJob {#3279
                +id: "16"
                +domain_id: "1"
                +run_frequency: "Daily"
                +last_run: null
                +scheduled_run_date: null
                +name: "Disable expired relationships"
                +description: "Disables relationships that have expired (ie. those relationships whose end date is in the past)."
                +api_entity: "Job"
                +api_action: "disable_expired_relationships"
                +parameters: null
                +is_active: "0"
                +action: null
                +class: null
                +apiParams: array:1 [
                  "version" => 3
                ]
                +remarks: []
              }
              3 => CRM_Core_ScheduledJob {#3280
                +id: "3"
                +domain_id: "1"
                +run_frequency: "Hourly"
                +last_run: null
                +scheduled_run_date: null
                +name: "Fetch Bounces"
                +description: "Fetches bounces from mailings and writes them to mailing statistics"
                +api_entity: "Job"
                +api_action: "fetch_bounces"
                +parameters: null
                +is_active: "0"
                +action: null
                +class: null
                +apiParams: array:1 [
                  "version" => 3
                ]
                +remarks: []
              }
              20 => CRM_Core_ScheduledJob {#3281
                +id: "20"
                +domain_id: "1"
                +run_frequency: "Daily"
                +last_run: "2024-03-31 02:00:09"
                +scheduled_run_date: null
                +name: "Firewall: Cleanup"
                +description: "Cleanup firewall table data"
                +api_entity: "Job"
                +api_action: "firewall_cleanup"
                +parameters: "delete_old_ipaddress=-1 month"
                +is_active: "1"
                +action: null
                +class: null
                +apiParams: array:2 [
                  "version" => 3
                  "delete_old_ipaddress" => "-1 month"
                ]
                +remarks: []
              }
              6 => CRM_Core_ScheduledJob {#3282
                +id: "6"
                +domain_id: "1"
                +run_frequency: "Daily"
                +last_run: null
                +scheduled_run_date: null
                +name: "Geocode and Parse Addresses"
                +description: "Retrieves geocodes (lat and long) and / or parses street addresses (populates street number, street name, etc.)"
                +api_entity: "Job"
                +api_action: "geocode"
                +parameters: """
                  geocoding=[1 or 0] required\n
                  parse=[1 or 0] required\n
                  start=[contact ID] optional-begin with this contact ID\n
                  end=[contact ID] optional-process contacts with IDs less than this\n
                  throttle=[1 or 0] optional-1 adds five second sleep
                  """
                +is_active: "0"
                +action: null
                +class: null
                +apiParams: array:6 [
                  "version" => 3
                  "geocoding" => "[1 or 0] required"
                  "parse" => "[1 or 0] required"
                  "start" => "[contact ID] optional-begin with this contact ID"
                  "end" => "[contact ID] optional-process contacts with IDs less than this"
                  "throttle" => "[1 or 0] optional-1 adds five second sleep"
                ]
                +remarks: []
              }
              26 => CRM_Core_ScheduledJob {#3283
                +id: "26"
                +domain_id: "1"
                +run_frequency: "Hourly"
                +last_run: "2024-03-31 16:00:12"
                +scheduled_run_date: null
                +name: "iATS Payments 1stPay Query Transactions"
                +description: "Call into iATS Payments 1stPay to get transactions (for auditing and verifying)."
                +api_entity: "Job"
                +api_action: "fapsquery"
                +parameters: null
                +is_active: "1"
                +action: null
                +class: null
                +apiParams: array:1 [
                  "version" => 3
                ]
                +remarks: []
              }
              28 => CRM_Core_ScheduledJob {#3284
                +id: "28"
                +domain_id: "1"
                +run_frequency: "Hourly"
                +last_run: "2024-03-31 16:00:12"
                +scheduled_run_date: null
                +name: "iATS Payments Get Legacy Transaction Journal"
                +description: "Call into iATS to get transaction journals, legacy processor (for auditing and verifying)."
                +api_entity: "Job"
                +api_action: "iatsreport"
                +parameters: null
                +is_active: "1"
                +action: null
                +class: null
                +apiParams: array:1 [
                  "version" => 3
                ]
                +remarks: []
              }
              27 => CRM_Core_ScheduledJob {#3272
                +id: "27"
                +domain_id: "1"
                +run_frequency: "Daily"
                +last_run: "2024-03-30 18:00:13"
                +scheduled_run_date: null
                +name: "iATS Payments Recurring Contributions"
                +description: "Trigger + Generate recurring contributions for iATS Payments"
                +api_entity: "Job"
                +api_action: "iatsrecurringcontributions"
                +parameters: null
                +is_active: "1"
                +action: null
                +class: null
                +apiParams: array:1 [
                  "version" => 3
                ]
                +remarks: []
              }
              29 => CRM_Core_ScheduledJob {#3270
                +id: "29"
                +domain_id: "1"
                +run_frequency: "Hourly"
                +last_run: "2024-03-31 16:00:12"
                +scheduled_run_date: null
                +name: "iATS Payments Verification"
                +description: "Verify payments from the iATS journal."
                +api_entity: "Job"
                +api_action: "iatsverify"
                +parameters: null
                +is_active: "1"
                +action: null
                +class: null
                +apiParams: array:1 [
                  "version" => 3
                ]
                +remarks: []
            
2
  • p.s. Outbound email is set to mail and test messages work. Commented Apr 1 at 4:38
  • Please, can anyone offer any insights based on the error log? Commented Apr 4 at 16:21

1 Answer 1

1

I looked at a system getting 'No database selected' from mailings. The problem in that case was down to the hosting environment: a combination of throttling outbound mails and a short MySQL timeout caused the db connection to timeout before the status was updated, resulting in that error. The solution there was to move to better hosting.

1
  • Thank you for the suggestion Aidan. I will take it up with the hosting company. Commented Apr 18 at 21:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.