IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 4, 2007, 1:36:46 PM (19 years ago)
Author:
jhoblitt
Message:

rework the getmountedvol() stored procedure to attempt to work around what appears to be some nasty transacational isolation leak throught that was causing getmountedvol() to randomly hang when nebdiskd changed the mount table.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Nebulous-Server/lib/Nebulous/Server/SQL.pm

    r13245 r13251  
    11# Copyright (c) 2004  Joshua Hoblitt
    22#
    3 # $Id: SQL.pm,v 1.39 2007-05-04 21:20:43 jhoblitt Exp $
     3# $Id: SQL.pm,v 1.40 2007-05-04 23:36:46 jhoblitt Exp $
    44
    55package Nebulous::Server::SQL;
     
    274274DROP TABLE IF EXISTS class;
    275275DROP TABLE IF EXISTS log;
     276DROP TABLE IF EXISTS mountedvol;
    276277DROP PROCEDURE IF EXISTS getmountedvol;
    277278SET FOREIGN_KEY_CHECKS=1
     
    386387###
    387388
     389CREATE TABLE mountedvol(
     390    mountpoint VARCHAR(255) NOT NULL,
     391    total BIGINT NOT NULL,
     392    used BIGINT NOT NULL,
     393    vol_id INT NOT NULL,
     394    name VARCHAR(255) NOT NULL,
     395    path VARCHAR(255) NOT NULL,
     396    allocate BOOLEAN DEFAULT FALSE,
     397    available BOOLEAN DEFAULT FALSE,
     398    KEY(vol_id),
     399    KEY(allocate),
     400    KEY(available)
     401) ENGINE=innodb;
     402
     403###
     404
    388405CREATE PROCEDURE getmountedvol() DETERMINISTIC
    389406BEGIN
     
    401418    SELECT @@session.tx_isolation INTO trans_level;
    402419
    403     -- set trans level
     420    -- set trans level to repeatable-read so the volume table does not change
     421    -- out from under our cursor
    404422    SET @@session.tx_isolation = 'REPEATABLE-READ';
    405 
    406     -- create a temp table to hold the merged results of the volume & mount
    407     -- tables.  One would hope the that the transaction isolation level will
    408     -- stop one session from stomping on another sessions version of this
    409     -- table.
    410 
    411     DROP TABLE IF EXISTS mountedvol;
    412     CREATE TEMPORARY TABLE mountedvol(
    413         mountpoint VARCHAR(255) NOT NULL,
    414         total BIGINT NOT NULL,
    415         used BIGINT NOT NULL,
    416         vol_id INT NOT NULL,
    417         name VARCHAR(255) NOT NULL,
    418         path VARCHAR(255) NOT NULL,
    419         allocate BOOLEAN DEFAULT FALSE,
    420         available BOOLEAN DEFAULT FALSE,
    421         KEY(vol_id),
    422         KEY(allocate),
    423         KEY(available)
    424     ) ENGINE=MEMORY;
    425423
    426424    -- iterate over the volume table finding the coresponding entry in the
    427425    -- mount table and inserting union of the volume & mount row into the
    428426    -- mountedvol table
    429 
    430427    OPEN cur1;
     428
     429    DELETE FROM mountedvol;
    431430
    432431    myloop: LOOP
     
    446445    -- restore the original transaction level
    447446    SET @@session.tx_isolation = trans_level;
     447
     448    COMMIT;
    448449END
Note: See TracChangeset for help on using the changeset viewer.