Skip to content

Conversation

@akilvein
Copy link
Contributor

#3745

Add option for TPersistentTable to lock the state file. Avoid state corruption if case of several vhosts accidentally start with the same parameters on the same machine.

@github-actions
Copy link
Contributor

Hi! Thank you for contributing!
The tests on this PR will run after a maintainer adds an ok-to-test label to this PR manually. Thank you for your patience!

@akilvein akilvein force-pushed the users/akilvein/persistent-table-files branch 3 times, most recently from eedeac6 to 276f827 Compare December 18, 2025 15:57
@debnatkh debnatkh added ok-to-test Label to approve test launch for external members filestore Add this label to run only cloud/filestore build and tests on PR labels Dec 31, 2025
@github-actions github-actions bot removed the ok-to-test Label to approve test launch for external members label Dec 31, 2025
@github-actions
Copy link
Contributor

Note

This is an automated comment that will be appended during run.

🟢 linux-x86_64-relwithdebinfo: all tests PASSED for commit 39947be.

TESTS PASSED ERRORS FAILED FAILED BUILD SKIPPED MUTED?
3123 3123 0 0 0 0 0

@akilvein akilvein force-pushed the users/akilvein/persistent-table-files branch from 39947be to 614e9b5 Compare December 31, 2025 12:59
@github-actions
Copy link
Contributor

Note

This is an automated comment that will be appended during run.

🟢 linux-x86_64-relwithdebinfo: all tests PASSED for commit 614e9b5.

TESTS PASSED ERRORS FAILED FAILED BUILD SKIPPED MUTED?
3273 3273 0 0 0 0 0

@budevg budevg self-requested a review January 22, 2026 14:36
NProto::TError TryInit(bool restoreClientSession)
{
auto handlesPath = StatePath / "handles";
auto indexPath = StatePath / "nodes";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are leaking implementation details from TLocalIndex into TSession. TSession shouldn't know that there is a "nodes" file which is used by the TIndex

auto handlesPath = StatePath / "handles";
auto indexPath = StatePath / "nodes";

if (!TryLockFile(handlesPath, HandlesFileLock) ||
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Locking handles here is premature because the file may be deleted later:

        if (isNewSession) {
            ...
            handlesPath.DeleteIfExists();

return makeResponse(*it->second);
}

auto clientSessionStatePath = StatePath / ("client_" + clientId);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually simplest and safest fix is to create a dedicated lock file in clientSessionStatePath (e.g. session.lock or state.lock) and never delete it. Then lock that file to guard the whole session state.

{
TTestBootstrap bootstrap;
bootstrap.CreateFileStore("fs", "cloud", "folder", 100500, 500100);
TTempDirectoryPtr bootstrapCwd;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there actually a new test that tests that it's forbidden to run two instances of same TSession ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ShouldFailToLockSessionStateTwice


Y_UNIT_TEST(ShouldRecoverSessionHandles)
{
TTestBootstrap bootstrap("fs", "client");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid extra refactoring in UTs, add CloseStore to TTestBootstrap and call it explicitly when needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

StopFileStore

TString expectedSessionId;

for (auto& file: files) {
auto handle =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to test this in devlab as well. Run filestore-vhost-local create fs, start endpoint attach vm. Then run another filestore-vhost-local process and see what happens

@akilvein akilvein force-pushed the users/akilvein/persistent-table-files branch from 614e9b5 to 0fb8d64 Compare January 25, 2026 23:29
@github-actions
Copy link
Contributor

github-actions bot commented Jan 26, 2026

Note

This is an automated comment that will be appended during run.

🔴 linux-x86_64-relwithdebinfo: some tests FAILED for commit 0fb8d64.

TESTS PASSED ERRORS FAILED FAILED BUILD SKIPPED MUTED?
3318 3317 0 1 0 0 0

🔴 linux-x86_64-relwithdebinfo: some tests FAILED for commit 0fb8d64.

TESTS PASSED ERRORS FAILED FAILED BUILD SKIPPED MUTED?
19 17 0 2 0 0 0

🟢 linux-x86_64-relwithdebinfo: all tests PASSED for commit 0fb8d64.

TESTS PASSED ERRORS FAILED FAILED BUILD SKIPPED MUTED?
19 19 0 0 0 0 0

@github-actions
Copy link
Contributor

github-actions bot commented Jan 26, 2026

Note

This is an automated comment that will be appended during run.

🔴 linux-x86_64-relwithdebinfo: some tests FAILED for commit c7cc5f8.

TESTS PASSED ERRORS FAILED FAILED BUILD SKIPPED MUTED?
3321 3319 0 2 0 0 0

🔴 linux-x86_64-relwithdebinfo: some tests FAILED for commit c7cc5f8.

TESTS PASSED ERRORS FAILED FAILED BUILD SKIPPED MUTED?
19 16 0 2 0 1 0

🟢 linux-x86_64-relwithdebinfo: all tests PASSED for commit c7cc5f8.

TESTS PASSED ERRORS FAILED FAILED BUILD SKIPPED MUTED?
19 19 0 0 0 0 0

void Init(bool restoreClientSession)
virtual ~TSession()
{
UnlockFile(SessionFileLock);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need destructor here ? The TFileLock will close the file when it's destroyed and this will unlock it automatically

UnlockFile(SessionFileLock);
}

NProto::TError TryInit(bool restoreClientSession)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can keep calling the function Init() and just add return value

}

auto clientSessionStatePath = StatePath / ("client_" + clientId);
clientSessionStatePath.MkDir();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually let's just move the whole session state lock logic here. Create TFileLock to guard the session state, lock it and move it to TSession. When the TSession object destroyed the file lock will be automatically released. Also let's do unit tests in session_ut.cpp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

filestore Add this label to run only cloud/filestore build and tests on PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants