lablup / lablup/backend.ai

Adopt fine-grained row-level lock options in SELECT queries

Open
#3,057 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
670
Forks
183
Avg merge
15h 13m
Merged PRs (30d)
368

Description

Currently we have just a `with_for_update` flag argument for several fetch functions for the sessions table.

Let's expand them to accept [more fine-grained options like skip_locked, read, etc.](https://docs.sqlalchemy.org/en/20/core/selectable.html#sqlalchemy.sql.expression.GenerativeSelect.with_for_update) to reduce the potential of serialization failures.(ref: [Teams thread](https://teams.microsoft.com/l/message/19:45a3dd9abdda4778bb66b9f9d3563055@thread.skype/1731037960287?tenantId=13c6a44d-9b52-4b9e-aa34-0513ee7131f2&groupId=74ae2c4d-ec4d-4fdf-b2c2-f5041d1e8631&parentMessageId=1731037960287&teamName=devops&channelName=Dev%20News&createdTime=1731037960287))

For example, `skip_locked` option could be useful to make the scheduler logic reentrant with less database overheads, by fetching disjoint sets of pending sessions excluding those being handled in prior overlapping transactions and belonging to different resource groups (#323).

JIRA Issue: BA-59

Contributor guide

Open the contributing guide

Research direction

Start by locating the session-table fetch functions that currently accept the with_for_update flag, then read SQLAlchemy's GenerativeSelect.with_for_update documentation linked in the issue. Check how the scheduler selects pending sessions and define done as all relevant fetch functions supporting the requested lock options without breaking existing callers.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, sqlalchemy
Domain
backend, databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.