Not directly, but you can query the locks on the file as per documentation:

    struct flock    v_pending;   // = { F_WRLCK, SEEK_SET, PENDING_BYTE  ,      
     1, 0};
    struct flock    v_reserved;  // = { F_WRLCK, SEEK_SET, RESERVED_BYTE ,      
     1, 0};
    struct flock    v_shared;    // = { F_WRLCK, SEEK_SET, SHARED_FIRST  , 
SHARED_SIZE, 0};
    int             v_fd        = -1;
    int             v_ret       = -1;

        memset( &v_pending, 0, sizeof( v_pending));
        v_pending.l_type        = F_WRLCK;
        v_pending.l_whence      = SEEK_SET;
        v_pending.l_start       = PENDING_BYTE;
        v_pending.l_len         = 1;
        v_pending.l_pid         = 0;

        memset( &v_reserved, 0, sizeof( v_reserved));
        v_reserved.l_type       = F_WRLCK;
        v_reserved.l_whence     = SEEK_SET;
        v_reserved.l_start      = RESERVED_BYTE;
        v_reserved.l_len        = 1;
        v_reserved.l_pid        = 0;

        memset( &v_shared, 0, sizeof( v_shared));
        v_shared.l_type         = F_WRLCK;
        v_shared.l_whence       = SEEK_SET;
        v_shared.l_start        = SHARED_FIRST;
        v_shared.l_len          = SHARED_SIZE;
        v_shared.l_pid          = 0;

    /* check for a PENDING lock */
    if (fcntl(v_fd,F_GETLK,&v_pending) == -1) {
<error handling>
    };
    /* check for a RESERVED lock */
    if (fcntl(v_fd,F_GETLK,&v_reserved) == -1) {
<error handling>    };
    /* check for a SHARED/EXCLUSIVE lock */
    if (fcntl(v_fd,F_GETLK,&v_shared) == -1) {
<error handling>    };

    if (v_pending.l_type == F_RDLCK)
        printf("%s File:%s, Process %d PENDING (SHARED)\n"   ,g_mode[v_mode] 
,v_file, (v_ret = v_pending .l_pid));

    if (v_shared .l_type == F_RDLCK)
        printf("%s File:%s, Process %d SHARED\n"             ,g_mode[v_mode] 
,v_file, (v_ret = v_shared  .l_pid));

    switch (v_reserved.l_type) {
        case F_WRLCK:
        case F_RDLCK:
        printf("%s File:%s, Process %d RESERVED\n"           ,g_mode[v_mode] 
,v_file, (v_ret = v_reserved.l_pid));
            break;
        default: break;
    }

    if (v_pending.l_type == F_WRLCK)
        printf("%s File: %s,Process %d PENDING (EXCLUSIVE)\n",g_mode[v_mode] 
,v_file, (v_ret = v_pending .l_pid));

    if (v_shared .l_type == F_WRLCK)
        printf("%s File %s, Process %d EXCLUSIVE\n"          ,g_mode[v_mode] 
,v_file, (v_ret = v_shared  .l_pid));

    if (v_ret == -1)
        printf("%s File:%s, <none>\n"                        ,g_mode[v_mode] 
,v_file);

-----Ursprüngliche Nachricht-----
Von: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] Im 
Auftrag von Bob Friesenhahn
Gesendet: Mittwoch, 01. März 2017 21:45
An: SQLite mailing list <sqlite-users@mailinglists.sqlite.org>
Betreff: Re: [sqlite] Database is locked

On Wed, 1 Mar 2017, Stephen Chrzanowski wrote:

> Where is the database being stored?  What OS is the software running
> under?  If Windows, I'd suggest looking up SysInternals and
> downloading the package to see what has its grubby hands on the
> database.  If Linux, as root, run an LSOF (Lower case) and grep for
> the database or process accessing the database.

This is an embedded Linux system.  Due to available resources, lsof is not 
available, but we can learn about open file descriptors from the /proc 
filesystem (via 'ls -l /proc/[pid]/fd').

Many of our processes have a database connection open all the time.  I am 
assuming that the problem is a hung (not commited or rolled back) transaction.  
I am hoping that sqlite provides a way to know what process is currently 
performing an update transaction.

Bob
--
Bob Friesenhahn
bfrie...@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


___________________________________________
 Gunter Hick
Software Engineer
Scientific Games International GmbH
FN 157284 a, HG Wien
Klitschgasse 2-4, A-1130 Vienna, Austria
Tel: +43 1 80100 0
E-Mail: h...@scigames.at

This communication (including any attachments) is intended for the use of the 
intended recipient(s) only and may contain information that is confidential, 
privileged or legally protected. Any unauthorized use or dissemination of this 
communication is strictly prohibited. If you have received this communication 
in error, please immediately notify the sender by return e-mail message and 
delete all copies of the original communication. Thank you for your cooperation.


_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to