Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add transactions to file writes and restore files to previous state when transactions fail #100

Merged
merged 8 commits into from
Sep 21, 2024

Conversation

xxfast
Copy link
Owner

@xxfast xxfast commented Apr 25, 2024

Addresses #91

  • Add missing documentation and labelled params
  • Update file codec to write to a temp file and move once completed
  • Add test cases

@SultanArshad
Copy link
Contributor

@xxfast Thanks for the fix any update on this when it was going to be in production thanks.

@xxfast
Copy link
Owner Author

xxfast commented Aug 20, 2024

Hi @SultanArshad planning this for 0.9.0 release. Stay tuned

…nsactions

# Conflicts:
#	kstore-file/src/commonMain/kotlin/io/github/xxfast/kstore/file/FileCodec.kt
#	kstore-file/src/commonMain/kotlin/io/github/xxfast/kstore/file/KStore.kt
#	kstore-file/src/commonTest/kotlin/io/github/xxfast/kstore/file/FileCodecTests.kt
@xxfast xxfast marked this pull request as ready for review September 8, 2024 03:17
@xxfast
Copy link
Owner Author

xxfast commented Sep 8, 2024

Hi @SultanArshad This is ready for review :)

Comment on lines +63 to +64
val actual: List<Pet>? = codec.decode()
assertEquals(listOf(MYLO), actual)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice work @xxfast! I’m wondering what happens if a race condition occurs and two different agents/threads start writing to a file at the same time, but one of them gets canceled or stopped. Does this revert the file back to an older version that was not modified? What happens to the version of the file being updated by the other agent/thread?

I suggest there should be a way to check if someone is modifying the file, and the other process should have to wait or be queued until the current modification is finished.

Copy link
Owner Author

Choose a reason for hiding this comment

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

There should really be a single store for a single file, but if there's an external process that is writing to the same file - and if the store write was cancelled, it should delete the temp file and leave the original file untouched

@xxfast xxfast merged commit cf083a6 into master Sep 21, 2024
10 checks passed
@xxfast xxfast deleted the ir/transactions branch September 21, 2024 00:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants