{"id":16485100,"url":"https://github.com/rivantsov/lockdemo","last_synced_at":"2026-06-09T02:01:31.607Z","repository":{"id":102970807,"uuid":"65094202","full_name":"rivantsov/LockDemo","owner":"rivantsov","description":"Demo app for the article about database locks for compound docs","archived":false,"fork":false,"pushed_at":"2016-10-12T18:28:40.000Z","size":17,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-01T00:09:51.083Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rivantsov.png","metadata":{"files":{"readme":"ReadMe.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-08-06T17:34:53.000Z","updated_at":"2022-07-02T09:39:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"0ec89a11-281f-43c9-a416-7502724af405","html_url":"https://github.com/rivantsov/LockDemo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rivantsov/LockDemo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rivantsov%2FLockDemo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rivantsov%2FLockDemo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rivantsov%2FLockDemo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rivantsov%2FLockDemo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rivantsov","download_url":"https://codeload.github.com/rivantsov/LockDemo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rivantsov%2FLockDemo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34088013,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-09T02:00:06.510Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T13:24:10.168Z","updated_at":"2026-06-09T02:01:31.575Z","avatar_url":"https://github.com/rivantsov.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"﻿# Database Locking Demo application\nThis small application is a sample code for the article about using database locks to ensure consistent loading and update of complex documents in relational databases. \n\n[Using locks to manage concurrent access to compound relational documents - for MS SQL and other servers](http://www.codeproject.com/Articles/1117051/Using-locks-to-manage-concurrent-access-to-compoun)\n\nThe app works several servers: MS SQL Server, MySql, Postgres, Oracle. \nBefore you run the application, you need to prepare the database:\n* Choose a server type and create LockTest database on (local) target server. (For MySql and Oracle - skip this, choose the target server installation)\n* Open SQL Browser app (SQL Management Studio, SQL browser) and run DDL script from DDLscripts folder to create database tables\n* Set ServerType and adjust connection string for target server in the app.config file. \nRun the app. Try changing 'UseLocks' in app.config and see the effects (errors) on the app execution. \n\n# What the app is doing  \nThe app works with 'documents' consisting of a header record (DocHeader table) and multiple DocDetail records. Each detail row contains 'Value' (int) column. DocHeader has a 'Total' column that is a sum of all values in related detail rows - this is a 'consistency' requirement.\nThe app initially creates several documents with multiple detail records each. The test starts 20+ threads, each repeating multple times a random operation over a randomly chosen document. An operation might be one the following: \n* Update - choose 3 random child detail rows, update them with random value in 'Value' column. Calculate new total and update the header row. \n* Read and check the total - load header and all detail rows for a random document, verify that total matches the sum of detail rows. If not - record it as a consistency check failure. \nWhen the tests are executed without locks, we get multiple deadlock and consistency load errors. If we use locks, the tests should run without any errors. \n\n**The purpose of the app is to demonstrate the correct locking implementation for consistent document read and update operations.** \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frivantsov%2Flockdemo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frivantsov%2Flockdemo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frivantsov%2Flockdemo/lists"}