Giter Club home page Giter Club logo

file-locking's Introduction

Test Concurrent Locking of Single File by Multiple Processes

This directory contains C++ test code for testing the locking of a single file by multiple processes. It was developed to test the behavior of the Lustre "global locking" feature which can be configured on or off. Problems arose when testing global locking with casacore. In these tests, it appeared as though using global locking with CASA resulted in deadlock.

Implementation

This test code is written in C++ (-std=c++20) and it uses cppzmq for queueing up actions for the parallel processes. The locking options are:

  • read lock on file immediately
  • write lock on file immediately
  • read lock on file at a specific time
  • write lock on file at a specific time
  • release lock immediately (whether held or not)
  • release lock immediately (if held)
  • release lock at a specific time (whether held or not)
  • release lock at a specific time (if held)

The only other command that the locking processes accepts is stop which cause them to exit.

Building

First install cppzmq. Then running make should build the test executables, running make clean should remove the built files and make package should create a tar file in ..

Running

The test can be run using ./controller /tmp/lock-file 10 which will start 10 locking processes which will try to lock /tmp/lock-file at the same time.

The current controller.cc code has all of the locking processes just attempt to acquire a write lock and then release it. This is done with the code:

send( "file@"+lock_file );
send( at(now( ) + seconds(1),"write") );
send( "releaseif" );
recv( []( const pair<pid_t,string> &r ) -> bool {
          cout << "Controller received: " << get<1>(r) << " from " << get<0>(r) << endl;
          return true;   /*** true means don't retain result in return ***/
      } );
send( "stop" );

The locking processes only send a result back to the controller when they encounter an empty command queue. This implementation is flexible and allows for testing complicated locking behavior.

Mon Mar 18 13:36:34 EDT 2024

Lustre "global" file locking (i.e. the locking across nodes that a distributed filesystem is expected to do) has not worked reliably. Due to this "local" locking has been used, i.e. file locking which is limited to single node. Switching to "global" file locking resulted in deadlock.

file-locking's People

Contributors

schiebel avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.