You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Bojan Smojver <bo...@rexursive.com> on 2006/04/17 06:51:39 UTC

SQLite3 BUSY return status

In this part of the code of the SQLite3 driver (function
dbd_sqlite3_select):

-----------------------------------------
if (ret == SQLITE_BUSY) {
    if (retry_count++ > MAX_RETRY_COUNT) {
        ret = SQLITE_ERROR;
} else {
    apr_dbd_mutex_unlock();
    apr_sleep(MAX_RETRY_SLEEP);
    apr_dbd_mutex_lock();
}
-----------------------------------------

We are returning SQLITE_ERROR when maximum number of retries has been
exhausted. However, the caller may want to know that there was no error,
but a timeout instead, therefore potentially retrying the operation from
the calling code (in fact, for high concurrency of requests, SQLITE3 is
very likely to give us this kind of behaviour). Maybe we should return
APR_TIMEUP or APR_EBUSY instead?

PS. I think returning native SQLITE3 or other database codes isn't very
useful anyway - the caller most likely won't have access to code
meanings (i.e. headers files) of native databases. I think we should be
returning APR error codes throughout DBD.

-- 
Bojan


Re: SQLite3 BUSY return status

Posted by Garrett Rooney <ro...@electricjellyfish.net>.
On 4/16/06, Bojan Smojver <bo...@rexursive.com> wrote:
> In this part of the code of the SQLite3 driver (function
> dbd_sqlite3_select):
>
> -----------------------------------------
> if (ret == SQLITE_BUSY) {
>     if (retry_count++ > MAX_RETRY_COUNT) {
>         ret = SQLITE_ERROR;
> } else {
>     apr_dbd_mutex_unlock();
>     apr_sleep(MAX_RETRY_SLEEP);
>     apr_dbd_mutex_lock();
> }
> -----------------------------------------
>
> We are returning SQLITE_ERROR when maximum number of retries has been
> exhausted. However, the caller may want to know that there was no error,
> but a timeout instead, therefore potentially retrying the operation from
> the calling code (in fact, for high concurrency of requests, SQLITE3 is
> very likely to give us this kind of behaviour). Maybe we should return
> APR_TIMEUP or APR_EBUSY instead?

+1, either of those would seen fine to me.

> PS. I think returning native SQLITE3 or other database codes isn't very
> useful anyway - the caller most likely won't have access to code
> meanings (i.e. headers files) of native databases. I think we should be
> returning APR error codes throughout DBD.

That would make sense to me.

-garrett