# Message: Begin failed with SQL exception

**URL:** https://www.finalbuilder.com/forums/t/message-begin-failed-with-sql-exception/6566
**Category:** Discussion
**Created:** [August 30, 2019, 7:14am UTC](https://www.finalbuilder.com/forums/t/message-begin-failed-with-sql-exception/6566 "2019-08-30T07:14:13Z")
**Posts on this page:** 20
**Page:** 2

<div class="post-metadata">

### Author: ![Sparky](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/sparky/32/10_2.png) [@Sparky](https://www.finalbuilder.com/forums/u/Sparky)
#### Post date: [August 30, 2019, 9:11am UTC](https://www.finalbuilder.com/forums/t/message-begin-failed-with-sql-exception/6566/21 "2019-08-30T09:11:00Z")

</div>

The only possible cause I can think of is that the database has become corrupted, although the error message would generally be different.

I recommend that you shutdown the `Continua CI PostgreSQL` service and take a full copy of the `C:\ProgramData\VSoft\ContinuaCI\PostgreSQLDB` folder before doing anything.

Then start up the service again and attempt to [backup the database](https://wiki.finalbuilder.com/display/continua/Backing+up+the+Continua+database).

Next see if there are any recent backup files. If you have upgraded recently, then there should be automatic back ups in the `C:\ProgramData\VSoft\ContinuaCI\PostgreSQLDB` folder. If the backups are recent enough, then try restoring over the database.

Otherwise there is a special option: `zero_damaged_pages=on` that you can use on postgresql.conf, see [this documentation](https://www.postgresql.org/docs/9.6/runtime-config-developer.html#GUC-ZERO-DAMAGED-PAGES), this will allow you to run pg\_dump without stopping on errors and may allow you to get a backup, although you will loose any data that cannot be read.

---

<div class="post-metadata">

### Author: ![sa\_thomaslohrum](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/s/ecd19e/32.png) [@sa\_thomaslohrum](https://www.finalbuilder.com/forums/u/sa_thomaslohrum)
#### Post date: [September 2, 2019, 9:35am UTC](https://www.finalbuilder.com/forums/t/message-begin-failed-with-sql-exception/6566/22 "2019-09-02T09:35:04Z")

</div>

Hi Dave,

we’re up and running our buildserver again. However, we still face issues.

1. When starting Windows we do need to start the PostgreSQL service after starting the Continua.Service to avoid a permant cpu usage of 100%.

2. Still Continua.Service triggers a cpu usage of 100% approximately every 30-40 seconds for about 34 seconds. Involved are Continua Agent Service and two instances of the WMI Provider Host. At this time no builds are running. Disk usage is down at 0-3 percent.

Our buildserver is running on Windows 10 Pro 1903 64-Bit. It’s a virtual machine on a Xeon 4 core processor (3.30 GHz) with 32 GB of RAM, of which the vm can use 6 GB.

---

<div class="post-metadata">

### Author: ![Vincent](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/vincent/32/938_2.png) [@Vincent](https://www.finalbuilder.com/forums/u/Vincent)
#### Post date: [September 2, 2019, 12:23pm UTC](https://www.finalbuilder.com/forums/t/message-begin-failed-with-sql-exception/6566/23 "2019-09-02T12:23:32Z")

</div>

Continua CI doesn’t do anything with WMI directly. The fact that the vm was moved to new hardware suggests an OS or VM configuration issue.

> **[Troubleshoot WMI Provider Host High CPU Usage issue in Windows 10/8/7](https://www.thewindowsclub.com/wmi-provider-host-high-cpu-usage)**
>
> This post shows you how to troubleshoot WmiPrvSE.exe or Windows Management Instrumentation Provider Service or WMI Provider Host High CPU Usage issue.

The above post shows how to diagnose which process is causing the high cpu usage on the wmi provider host.

Also, what hypervisor is the VM running on?

---

<div class="post-metadata">

### Author: ![Vincent](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/vincent/32/938_2.png) [@Vincent](https://www.finalbuilder.com/forums/u/Vincent)
#### Post date: [September 2, 2019, 12:31pm UTC](https://www.finalbuilder.com/forums/t/message-begin-failed-with-sql-exception/6566/24 "2019-09-02T12:31:09Z")

</div>

BTW, if you haven’t already looked at this blog post

[https://www.finalbuilder.com/resources/blogs/continuous-integration-server-performance](https://www.finalbuilder.com/resources/blogs/continuous-integration-server-performance)

I would highly recommend taking a look, in particular the part about antivirus software.

Also enable debug logging [https://wiki.finalbuilder.com/display/continua/Debug+Logging](https://wiki.finalbuilder.com/display/continua/Debug+Logging) and wait till you sees the cpu spike, the stop the service (and turn of debug logging) and send us the log file.

---

<div class="post-metadata">

### Author: ![sa\_thomaslohrum](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/s/ecd19e/32.png) [@sa\_thomaslohrum](https://www.finalbuilder.com/forums/u/sa_thomaslohrum)
#### Post date: [September 2, 2019, 1:06pm UTC](https://www.finalbuilder.com/forums/t/message-begin-failed-with-sql-exception/6566/25 "2019-09-02T13:06:00Z")

</div>

Hi Vincent,

thanks for your reply. I will check and let you know the results.

---

<div class="post-metadata">

### Author: ![Sparky](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/sparky/32/10_2.png) [@Sparky](https://www.finalbuilder.com/forums/u/Sparky)
#### Post date: [September 5, 2019, 6:28am UTC](https://www.finalbuilder.com/forums/t/message-begin-failed-with-sql-exception/6566/26 "2019-09-05T06:28:27Z")

</div>

Hi Thomas,

Are you still seeing database errors and high CPU issues?

---

<div class="post-metadata">

### Author: ![sa\_thomaslohrum](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/s/ecd19e/32.png) [@sa\_thomaslohrum](https://www.finalbuilder.com/forums/u/sa_thomaslohrum)
#### Post date: [September 5, 2019, 7:34am UTC](https://www.finalbuilder.com/forums/t/message-begin-failed-with-sql-exception/6566/27 "2019-09-05T07:34:26Z")

</div>

Hi Dave,

i’ve just checked the event log and found entries such as:

> Die Beschreibung für die Ereignis-ID “0” aus der Quelle “PostgreSQL” wurde nicht gefunden. Entweder ist die Komponente, die dieses Ereignis auslöst, nicht auf dem lokalen Computer installiert, oder die Installation ist beschädigt. Sie können die Komponente auf dem lokalen Computer installieren oder reparieren.
> 
> Falls das Ereignis auf einem anderen Computer aufgetreten ist, mussten die Anzeigeinformationen mit dem Ereignis gespeichert werden.
> 
> Die folgenden Informationen wurden mit dem Ereignis gespeichert:
> 
> FATAL: Verbindung wird abgebrochen aufgrund von Anweisung des Administrators

Last Friday we encountered an issue which we worked around by manually starting the postgresql service after the continua service to get things running. I need to enable debug logging and restart Continua to provide more details. However, i need to find a timeframe to do so first.

About the cpu usage we were able to chase things down to the way Continua refreshes (git) repositories.  
The default setting for “Server.RepoMonitor.MaxCheckers” is ‘5’, which caused the high load. Reducing it to a value of ‘2’ immediately helped. In the end we configurared a value of ‘1’. This results in a permanent and steady load of 35-40% cpu usage. As Vincent suggested we need to check server requirements. We may upgrade to a server with more power, especially more cpu cores. Interesting is that each “git fetch”, issued to gather information, causes a high load. To some extend the problems are caused by git. To further reduce cpu load we also reduced repo polling downto 5 minutes, rather than the default of 60 seconds. We also configured some repos to poll “manually”.

---

<div class="post-metadata">

### Author: ![Sparky](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/sparky/32/10_2.png) [@Sparky](https://www.finalbuilder.com/forums/u/Sparky)
#### Post date: [September 5, 2019, 7:51am UTC](https://www.finalbuilder.com/forums/t/message-begin-failed-with-sql-exception/6566/28 "2019-09-05T07:51:29Z")

</div>

How many git repositories do you have? Are they large repositories? I’m just checking the git processes and they are hardly getting past 0 CPU.

The error points to an issue with your database. What’s the size of the database, and the number of records in the larger tables e.g. build\_builds and builds\_unittestv2. It may be that your database indexes have become bloated, so it may be worth running a `REINDEX DATABASE` command.

---

<div class="post-metadata">

### Author: ![sa\_thomaslohrum](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/s/ecd19e/32.png) [@sa\_thomaslohrum](https://www.finalbuilder.com/forums/u/sa_thomaslohrum)
#### Post date: [September 5, 2019, 8:05am UTC](https://www.finalbuilder.com/forums/t/message-begin-failed-with-sql-exception/6566/29 "2019-09-05T08:05:43Z")

</div>

> [@Sparky](#):
>
> How many git repositories do you have? Are they large repositories? I’m just checking the git processes and they are hardly getting past 0 CPU.

It’s 32 active repos only. One of them is around 5 GB. The others are much smaller, that is less than 100 MB.

---

<div class="post-metadata">

### Author: ![sa\_thomaslohrum](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/s/ecd19e/32.png) [@sa\_thomaslohrum](https://www.finalbuilder.com/forums/u/sa_thomaslohrum)
#### Post date: [September 5, 2019, 8:07am UTC](https://www.finalbuilder.com/forums/t/message-begin-failed-with-sql-exception/6566/30 "2019-09-05T08:07:45Z")

</div>

> [@Sparky](#):
>
> The error points to an issue with your database. What’s the size of the database, and the number of records in the larger tables e.g. build\_builds and builds\_unittestv2. It may be that your database indexes have become bloated, so it may be worth running a `REINDEX DATABASE` command.

I found another entry in the event log:

> Die Beschreibung für die Ereignis-ID “0” aus der Quelle “PostgreSQL” wurde nicht gefunden. Entweder ist die Komponente, die dieses Ereignis auslöst, nicht auf dem lokalen Computer installiert, oder die Installation ist beschädigt. Sie können die Komponente auf dem lokalen Computer installieren oder reparieren.
> 
> Falls das Ereignis auf einem anderen Computer aufgetreten ist, mussten die Anzeigeinformationen mit dem Ereignis gespeichert werden.
> 
> Die folgenden Informationen wurden mit dem Ereignis gespeichert:
> 
> FEHLER: Relation »builds\_unittest« existiert nicht bei Zeichen 16  
> ANWEISUNG: SELECT id FROM builds\_unittest limit 1

---

<div class="post-metadata">

### Author: ![Sparky](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/sparky/32/10_2.png) [@Sparky](https://www.finalbuilder.com/forums/u/Sparky)
#### Post date: [September 5, 2019, 8:27am UTC](https://www.finalbuilder.com/forums/t/message-begin-failed-with-sql-exception/6566/31 "2019-09-05T08:27:17Z")

</div>

> [@sa\_thomaslohrum](#):
>
> FEHLER: Relation »builds\_unittest« existiert nicht bei Zeichen 16  
> ANWEISUNG: SELECT id FROM builds\_unittest limit 1

That’s normal. `builds_unittest` has been replaced with `builds_unittestv2` but we run a test to see if it exists for backward compatibility.

---

<div class="post-metadata">

### Author: ![sa\_thomaslohrum](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/s/ecd19e/32.png) [@sa\_thomaslohrum](https://www.finalbuilder.com/forums/u/sa_thomaslohrum)
#### Post date: [September 5, 2019, 2:50pm UTC](https://www.finalbuilder.com/forums/t/message-begin-failed-with-sql-exception/6566/32 "2019-09-05T14:50:06Z")

</div>

Sent debug log regarding cpu usage by private mail.

---

<div class="post-metadata">

### Author: ![sa\_thomaslohrum](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/s/ecd19e/32.png) [@sa\_thomaslohrum](https://www.finalbuilder.com/forums/u/sa_thomaslohrum)
#### Post date: [September 5, 2019, 2:51pm UTC](https://www.finalbuilder.com/forums/t/message-begin-failed-with-sql-exception/6566/33 "2019-09-05T14:51:32Z")

</div>

As for the socket error we encounter a reindex operation did not fix it. Using pgAdmin i am not able to query data. However when working with Continua we don’t encounter any issues so far.

---

<div class="post-metadata">

### Author: ![sa\_thomaslohrum](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/s/ecd19e/32.png) [@sa\_thomaslohrum](https://www.finalbuilder.com/forums/u/sa_thomaslohrum)
#### Post date: [September 5, 2019, 2:54pm UTC](https://www.finalbuilder.com/forums/t/message-begin-failed-with-sql-exception/6566/34 "2019-09-05T14:54:04Z")

</div>

Vincent’s blog notes:

> 1. Manual polling, using post commit hooks. This reduces CPU usage on the server, by only polling for repository changes when requested and has the added benefit of reducing the load on your version control server. This does take some setting up, and depends very much on the capabilities of your version control system. I’ll take a look at post commit hooks in a future blog post.  
> [Continuous Integration Server performance](https://www.finalbuilder.com/resources/blogs/continuous-integration-server-performance)

Is this something that has been researched yet? We’re using TFS 2017, but installing (Azure DevOps Server 2019 is no problem.

---

<div class="post-metadata">

### Author: ![Sparky](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/sparky/32/10_2.png) [@Sparky](https://www.finalbuilder.com/forums/u/Sparky)
#### Post date: [September 6, 2019, 4:52am UTC](https://www.finalbuilder.com/forums/t/message-begin-failed-with-sql-exception/6566/35 "2019-09-06T04:52:42Z")

</div>

Hi Thomas,

Thank you for sending the debug log. We can find no errors, timeouts or slow operations in the 20 minutes logged, so there’s not really anything there for us to investigate. The git fetch commands are fast, but there are no new changesets. A longer debug log which is enabled while the above errors are occurring may be more fruitful.

It is possible to add a service hook to TFS/DevOps server to call a URL. Note however that your Continua CI server website will need to be accessible to the TFS/DevOps server.

Under the TFS project settings, on the `Service Hooks` tab, you can create an new subscription to integrate with a Web Hooks service. Select the `Code pushed` trigger event and your repository, then enter the repository `Manual Poll URL`.

Of course, when we re-tested this today it did not start a repository check. TFS sends an id in its request which overrides the id in the url. We’ll fix this for the next version.

We’re more concerned about you not being able to query the database using pgAdmin4 and the `FATAL: Verbindung wird abgebrochen aufgrund von Anweisung des Administrators` error message. If you backup the database using `pg_dump.exe`, is it successful or are there any errors?

---

<div class="post-metadata">

### Author: ![sa\_thomaslohrum](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/s/ecd19e/32.png) [@sa\_thomaslohrum](https://www.finalbuilder.com/forums/u/sa_thomaslohrum)
#### Post date: [September 9, 2019, 7:06am UTC](https://www.finalbuilder.com/forums/t/message-begin-failed-with-sql-exception/6566/36 "2019-09-09T07:06:47Z")

</div>

Hi Dave,

thanks for checking the log. For the time being no further action necessary. As for the TFS Hook i will give that a try, when the Continua fix is available. As for the database errors i can execute pg\_dump with no errors.

Command used: pg\_dump -U username -W -F t ContinuaCI \> c:\BAK\ContinuaCI.tar

---

<div class="post-metadata">

### Author: ![Sparky](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/sparky/32/10_2.png) [@Sparky](https://www.finalbuilder.com/forums/u/Sparky)
#### Post date: [September 9, 2019, 7:40am UTC](https://www.finalbuilder.com/forums/t/message-begin-failed-with-sql-exception/6566/37 "2019-09-09T07:40:14Z")

</div>

OK, let us know if you have any further issues with the database.

Note that version [1.9.1.336](https://www.finalbuilder.com/downloads/continuaci/continua-ci-version-history-v191) includes the update to the repository polling endpoint to support triggering from a TFS web hook

---

<div class="post-metadata">

### Author: ![sa\_thomaslohrum](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/s/ecd19e/32.png) [@sa\_thomaslohrum](https://www.finalbuilder.com/forums/u/sa_thomaslohrum)
#### Post date: [September 9, 2019, 2:54pm UTC](https://www.finalbuilder.com/forums/t/message-begin-failed-with-sql-exception/6566/38 "2019-09-09T14:54:11Z")

</div>

> [@Sparky](#):
>
> Note that version [1.9.1.336](https://www.finalbuilder.com/downloads/continuaci/continua-ci-version-history-v191) includes the update to the repository polling endpoint to support triggering from a TFS web hook

I configured a Web Hook Action “Post via HTTP”. For the URL i configured the root of our ContinuaCI Server. TFS triggers the event, when i push commits to the repository. However, the action fails with “Not Found (404)”.

Any ideas?

---

<div class="post-metadata">

### Author: ![Sparky](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/sparky/32/10_2.png) [@Sparky](https://www.finalbuilder.com/forums/u/Sparky)
#### Post date: [September 9, 2019, 11:41pm UTC](https://www.finalbuilder.com/forums/t/message-begin-failed-with-sql-exception/6566/39 "2019-09-09T23:41:05Z")

</div>

Works for us 🤔.

Did you copy the `Manual Poll URL` correctly from the repository settings? Is the URL accessible from the TFS server? I assume this is an on-premises TFS server, can you log on to it and browse to the URL?

---

<div class="post-metadata">

### Author: ![sa\_thomaslohrum](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/s/ecd19e/32.png) [@sa\_thomaslohrum](https://www.finalbuilder.com/forums/u/sa_thomaslohrum)
#### Post date: [September 10, 2019, 6:12am UTC](https://www.finalbuilder.com/forums/t/message-begin-failed-with-sql-exception/6566/40 "2019-09-10T06:12:24Z")

</div>

Works for me too 🤣

Just need to enter the correct Manual Poll URL. As often the problem resides in front of the computer. However, there is an issue with ContinuaCI’s repository dialog. After you change the Polling Frequence to “Never (Manual)” the URL field will not be displayed! You must save and close the dialog first. After reopening the dialog the URL will be visible.

Thanks for your help!

[Previous page](https://www.finalbuilder.com/forums/t/message-begin-failed-with-sql-exception/6566.md?page=1)

[Next page](https://www.finalbuilder.com/forums/t/message-begin-failed-with-sql-exception/6566.md?page=3)
