### Description

The permissions module has two reload RPC commands, `permissions.addressReload` 
which reloads the `address` table, and `permissions.trustedReload`, which 
reloads the `trusted` table.

The module parameter `reload_delta` exists to prevent concurrent reloading of a 
single table:
> ##### 3.25. reload_delta (int)
> The number of seconds that have to be waited before executing a new RPC 
> reload. By default there is a rate limiting of maximum one reload in five 
> seconds.
> 
> If set to 0, no rate limit is configured. Note carefully: use this 
> configuration only in tests environments because executing two RPC reloads of 
> the same table at the same time can cause to kamailio to crash.

If one of the reload rpc commands is issues (i.e. `permissions.addressReload`), 
then the OTHER reload command (`permissions.trustedReload`) will be blocked, 
despite acting against two separate tables.


### Troubleshooting

Reproduced the issue.

#### Reproduction

_(DB config for permissions module omitted for brevity)_
```
loadmodule "rtimer.so"
loadmodule "permissions.so"
loadmodule "jsonrpcs"

modparamx("rtimer", "timer", "name=permissions_reload;mode=0;interval=300")
modparam("rtimer", "exec", "timer=permissions_reload;route=RELOAD_PERMISSIONS")


route[RELOAD_PERMISSIONS] {
    xnotice("Reloading trusted records\n");
    jsonrpc_exec('{"jsonrpc": "2.0", "method": "permissions.trustedReload", 
"id": 1}');
    xalert("jsonrpc response code: $jsonrpl(code) - the body is: 
$jsonrpl(body)\n");

    xnotice("Reloading addresses\n");
    jsonrpc_exec('{"jsonrpc": "2.0", "method": "permissions.addressReload", 
"id": 1}');
    xalert("jsonrpc response code: $jsonrpl(code) - the body is: 
$jsonrpl(body)\n");

}
```

#### Debugging Data

The above config yields output like this:

```
2(8) NOTICE: <script>: Reloading trusted records
2(8) ALERT: <script>: jsonrpc response code: 200 - the body is: {
    "jsonrpc":      "2.0",
    "result":       "Reload OK",
    "id":   1
}
2(8) NOTICE: <script>: Reloading addresses
2(8) ERROR: permissions [rpc.c:42]: rpc_check_reload(): ongoing reload
2(8) ALERT: <script>: jsonrpc response code: 500 - the body is: {
    "jsonrpc":      "2.0",
    "error":        {
        "code": 500,
        "message":      "ongoing reload"
    },
    "id":   1
}
```


### Possible Solutions

Ideally each reload would be tracked separately.  This could possibly involve 
separate `reload_delta` parameters for each table (although it seems excessive 
to change the interface).  

It's also possible that this behavior is by design, in which case, 
clarification of the documentation for the `reload_delta` parameter would be 
nice.

### Additional Information

Problem occurs in kamailio 5.6.2.  Likely within all version since the 
`reload_delta` parameter was added.

* **Operating System**:

Tested in Alpine, but OS seems irrelevant.


-- 
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/3318
You are receiving this because you are subscribed to this thread.

Message ID: <kamailio/kamailio/issues/3...@github.com>
_______________________________________________
Kamailio (SER) - Development Mailing List
To unsubscribe send an email to sr-dev-le...@lists.kamailio.org

Reply via email to