<p>The issue here is that the sql_connect() bind and initialize the internal database handle structure. If this is not properly done, the module can't operate later on the database. If you want to implement a change like this, I would suggest to dig a bit deeper in the code.</p>
<p>One idea would be to periodically trigger (e.g. with a timer) a check if the DB got available, and then initialize it properly. Probably also necessary would be a protection of every DB access with a lock, to prevent errors during the initialization (because of the Kamailio multi-process architecture).</p>
<p>If you are interested in digging into that feel free to discuss your approach on our sr-dev list. If you managed to get a first working version, then just open a pull request for a review.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/kamailio/kamailio/issues/1681#issuecomment-434464872">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AF36ZfrJ-UZ_UlJYuFG2RiFBEbPWr4p7ks5uqL0CgaJpZM4XvXbj">mute the thread</a>.<img src="https://github.com/notifications/beacon/AF36ZZGVggCiGdCFNKrvhPZGElY8GQMUks5uqL0CgaJpZM4XvXbj.gif" height="1" width="1" alt="" /></p>
<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/kamailio/kamailio","title":"kamailio/kamailio","subtitle":"GitHub repository","main_image_url":"https://assets-cdn.github.com/images/email/message_cards/header.png","avatar_image_url":"https://assets-cdn.github.com/images/email/message_cards/avatar.png","action":{"name":"Open in GitHub","url":"https://github.com/kamailio/kamailio"}},"updates":{"snippets":[{"icon":"PERSON","message":"@henningw in #1681: The issue here is that the sql_connect() bind and initialize the internal database handle structure. If this is not properly done, the module can't operate later on the database. If you want to implement a change like this, I would suggest to dig a bit deeper in the code.\r\n\r\nOne idea would be to periodically trigger (e.g. with a timer) a check if the DB got available, and then initialize it properly. Probably also necessary would be a protection of every DB access with a lock, to prevent errors during the initialization (because of the Kamailio multi-process architecture).\r\n \r\nIf you are interested in digging into that feel free to discuss your approach on our sr-dev list. If you managed to get a first working version, then just open a pull request for a review."}],"action":{"name":"View Issue","url":"https://github.com/kamailio/kamailio/issues/1681#issuecomment-434464872"}}}</script>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/kamailio/kamailio/issues/1681#issuecomment-434464872",
"url": "https://github.com/kamailio/kamailio/issues/1681#issuecomment-434464872",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
},
{
"@type": "MessageCard",
"@context": "http://schema.org/extensions",
"hideOriginalBody": "false",
"originator": "AF6C5A86-E920-430C-9C59-A73278B5EFEB",
"title": "Re: [kamailio/kamailio] sqlops offline database start and live re-connect (#1681)",
"sections": [
{
"text": "",
"activityTitle": "**Henning Westerholt**",
"activityImage": "https://assets-cdn.github.com/images/email/message_cards/avatar.png",
"activitySubtitle": "@henningw",
"facts": [

]
}
],
"potentialAction": [
{
"name": "Add a comment",
"@type": "ActionCard",
"inputs": [
{
"isMultiLine": true,
"@type": "TextInput",
"id": "IssueComment",
"isRequired": false
}
],
"actions": [
{
"name": "Comment",
"@type": "HttpPOST",
"target": "https://api.github.com",
"body": "{\n\"commandName\": \"IssueComment\",\n\"repositoryFullName\": \"kamailio/kamailio\",\n\"issueId\": 1681,\n\"IssueComment\": \"{{IssueComment.value}}\"\n}"
}
]
},
{
"name": "Close issue",
"@type": "HttpPOST",
"target": "https://api.github.com",
"body": "{\n\"commandName\": \"IssueClose\",\n\"repositoryFullName\": \"kamailio/kamailio\",\n\"issueId\": 1681\n}"
},
{
"targets": [
{
"os": "default",
"uri": "https://github.com/kamailio/kamailio/issues/1681#issuecomment-434464872"
}
],
"@type": "OpenUri",
"name": "View on GitHub"
},
{
"name": "Unsubscribe",
"@type": "HttpPOST",
"target": "https://api.github.com",
"body": "{\n\"commandName\": \"MuteNotification\",\n\"threadId\": 398292707\n}"
}
],
"themeColor": "26292E"
}
]</script>