You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@kvrocks.apache.org by GitBox <gi...@apache.org> on 2023/02/20 04:10:13 UTC

[GitHub] [incubator-kvrocks] isnowly created a discussion: Is the mset command atomicity?

GitHub user isnowly created a discussion: Is the mset command atomicity?

Hi, guys

I'm just getting started with kvsocks and it has a lot to offer me. But I don't know enough about it. I know it is based on rocksdb, and rocksdb supports transactions, so does the `mset` command have the atomicity of transactions? When the system fails, will the previous insertion be automatically rolled back? Thanks.

Regards

GitHub link: https://github.com/apache/incubator-kvrocks/discussions/1266

----
This is an automatically sent email for issues@kvrocks.apache.org.
To unsubscribe, please send an email to: issues-unsubscribe@kvrocks.apache.org


[GitHub] [incubator-kvrocks] git-hulk added a comment to the discussion: Is the mset command atomicity?

Posted by GitBox <gi...@apache.org>.
GitHub user git-hulk added a comment to the discussion: Is the mset command atomicity?

Sure, It should be easy to improve the mset command, but the multi/exec should have a lot of work to achieve this.

GitHub link: https://github.com/apache/incubator-kvrocks/discussions/1266#discussioncomment-5074664

----
This is an automatically sent email for issues@kvrocks.apache.org.
To unsubscribe, please send an email to: issues-unsubscribe@kvrocks.apache.org


[GitHub] [incubator-kvrocks] git-hulk added a comment to the discussion: Is the mset command atomicity?

Posted by GitBox <gi...@apache.org>.
GitHub user git-hulk added a comment to the discussion: Is the mset command atomicity?

It's NOT an atomic operation in MSET command, but we can improve it since we supports multi-key locks now.

For more detail can see: https://github.com/apache/incubator-kvrocks/blob/unstable/src/types/redis_string.cc#L356

GitHub link: https://github.com/apache/incubator-kvrocks/discussions/1266#discussioncomment-5050013

----
This is an automatically sent email for issues@kvrocks.apache.org.
To unsubscribe, please send an email to: issues-unsubscribe@kvrocks.apache.org


[GitHub] [kvrocks] git-hulk added a comment to the discussion: Is the mset command atomicity?

Posted by "git-hulk (via GitHub)" <gi...@apache.org>.
GitHub user git-hulk added a comment to the discussion: Is the mset command atomicity?

You're welcome

GitHub link: https://github.com/apache/kvrocks/discussions/1266#discussioncomment-6746351

----
This is an automatically sent email for issues@kvrocks.apache.org.
To unsubscribe, please send an email to: issues-unsubscribe@kvrocks.apache.org


[GitHub] [kvrocks] git-hulk edited a comment on the discussion: Is the mset command atomicity?

Posted by "git-hulk (via GitHub)" <gi...@apache.org>.
GitHub user git-hulk edited a comment on the discussion: Is the mset command atomicity?

> can any reader observe the existence of the hash before it is fully constructed?

Unfortunately, it's not, because the reader will always use the snapshot when reading the data to avoid blocking by the write operation.

> can any reader see that the hash exists, but fail to HGET one of the keys that the writer added/is-still-in-the-process-of-adding to the new hash?

No, all key-values will be submitted at once or nothing, for readers can't see it before committing.

GitHub link: https://github.com/apache/kvrocks/discussions/1266#discussioncomment-6742669

----
This is an automatically sent email for issues@kvrocks.apache.org.
To unsubscribe, please send an email to: issues-unsubscribe@kvrocks.apache.org


[GitHub] [kvrocks] ediphy-dwild added a comment to the discussion: Is the mset command atomicity?

Posted by "ediphy-dwild (via GitHub)" <gi...@apache.org>.
GitHub user ediphy-dwild added a comment to the discussion: Is the mset command atomicity?

perfect - that explains things. thankyou very much for your time!

GitHub link: https://github.com/apache/kvrocks/discussions/1266#discussioncomment-6743115

----
This is an automatically sent email for issues@kvrocks.apache.org.
To unsubscribe, please send an email to: issues-unsubscribe@kvrocks.apache.org


[GitHub] [kvrocks] git-hulk added a comment to the discussion: Is the mset command atomicity?

Posted by "git-hulk (via GitHub)" <gi...@apache.org>.
GitHub user git-hulk added a comment to the discussion: Is the mset command atomicity?

> are you saying that a reader can see a partially constructed hash (really bad, for our use case) or that readers cannot see a partially constructed hash (our expected behaviour).

No indeed, readers cannot see anything before the writer committed.

GitHub link: https://github.com/apache/kvrocks/discussions/1266#discussioncomment-6742886

----
This is an automatically sent email for issues@kvrocks.apache.org.
To unsubscribe, please send an email to: issues-unsubscribe@kvrocks.apache.org


[GitHub] [incubator-kvrocks] git-hulk added a comment to the discussion: Is the mset command atomicity?

Posted by GitBox <gi...@apache.org>.
GitHub user git-hulk added a comment to the discussion: Is the mset command atomicity?

RocksDB supports write batch, we can commit those mset key values at once instead of one by one.

GitHub link: https://github.com/apache/incubator-kvrocks/discussions/1266#discussioncomment-5051666

----
This is an automatically sent email for issues@kvrocks.apache.org.
To unsubscribe, please send an email to: issues-unsubscribe@kvrocks.apache.org


[GitHub] [kvrocks] ediphy-dwild added a comment to the discussion: Is the mset command atomicity?

Posted by "ediphy-dwild (via GitHub)" <gi...@apache.org>.
GitHub user ediphy-dwild added a comment to the discussion: Is the mset command atomicity?

related clarification question:

in the absence of any failure:
 - if a writer performs a single HMSET command
 - can any reader observe the existence of the hash before it is fully constructed?

one example of this potential race:
 - a writer creates a hash of 200K key values with a single HMSET
 - can any reader see that the hash exists, but fail to HGET one of the keys that the writer added/is-still-in-the-process-of-adding to the new hash?
 - or can a reader HGET one of the keys but fail to HGET another key - but then try again 'later' and succeed for both keys?

many thanks in advance

GitHub link: https://github.com/apache/kvrocks/discussions/1266#discussioncomment-6742641

----
This is an automatically sent email for issues@kvrocks.apache.org.
To unsubscribe, please send an email to: issues-unsubscribe@kvrocks.apache.org


[GitHub] [incubator-kvrocks] tarvfx added a comment to the discussion: Is the mset command atomicity?

Posted by GitBox <gi...@apache.org>.
GitHub user tarvfx added a comment to the discussion: Is the mset command atomicity?

That's really nice. I'm looking forward to it. I don't know how to develop in C++, otherwise I would submit a PR.


GitHub link: https://github.com/apache/incubator-kvrocks/discussions/1266#discussioncomment-5076453

----
This is an automatically sent email for issues@kvrocks.apache.org.
To unsubscribe, please send an email to: issues-unsubscribe@kvrocks.apache.org


[GitHub] [kvrocks] git-hulk added a comment to the discussion: Is the mset command atomicity?

Posted by "git-hulk (via GitHub)" <gi...@apache.org>.
GitHub user git-hulk added a comment to the discussion: Is the mset command atomicity?

> can any reader observe the existence of the hash before it is fully constructed?
Unfortunately, it's not, because the reader will always use the snapshot when reading the data to avoid blocking by the write operation.

GitHub link: https://github.com/apache/kvrocks/discussions/1266#discussioncomment-6742669

----
This is an automatically sent email for issues@kvrocks.apache.org.
To unsubscribe, please send an email to: issues-unsubscribe@kvrocks.apache.org


[GitHub] [kvrocks] git-hulk edited a comment on the discussion: Is the mset command atomicity?

Posted by "git-hulk (via GitHub)" <gi...@apache.org>.
GitHub user git-hulk edited a comment on the discussion: Is the mset command atomicity?

> can any reader observe the existence of the hash before it is fully constructed?

Unfortunately, it's not, because the reader will always use the snapshot when reading the data to avoid blocking by the write operation.

> can any reader see that the hash exists, but fail to HGET one of the keys that the writer added/is-still-in-the-process-of-adding to the new hash?

No, all key-values will be submitted at once or nothing, so readers can't see it before committing.

GitHub link: https://github.com/apache/kvrocks/discussions/1266#discussioncomment-6742669

----
This is an automatically sent email for issues@kvrocks.apache.org.
To unsubscribe, please send an email to: issues-unsubscribe@kvrocks.apache.org


[GitHub] [incubator-kvrocks] isnowly added a comment to the discussion: Is the mset command atomicity?

Posted by GitBox <gi...@apache.org>.
GitHub user isnowly added a comment to the discussion: Is the mset command atomicity?

Hi, @git-hulk 

Thank you for your clarification. 

Things looked different than I expected. Now I have a batch of key values that need to be inserted, but I want them to be executed in the same transaction (`rollback` if it fails). For this I am looking for a solution. Redis has transactions, but it doesn't seem to be complete as it can't handle rollbacks. Can you tell me how kvrocks achieves this? Thanks.

Regards

GitHub link: https://github.com/apache/incubator-kvrocks/discussions/1266#discussioncomment-5050718

----
This is an automatically sent email for issues@kvrocks.apache.org.
To unsubscribe, please send an email to: issues-unsubscribe@kvrocks.apache.org


[GitHub] [incubator-kvrocks] tarvfx added a comment to the discussion: Is the mset command atomicity?

Posted by GitBox <gi...@apache.org>.
GitHub user tarvfx added a comment to the discussion: Is the mset command atomicity?

Hi, @git-hulk

Maybe some want it to be like redis! Will the development team agree to this improvement? Can the multi and exec command combination of kvrocks automatically roll back after an unexpected error?

Regards

GitHub link: https://github.com/apache/incubator-kvrocks/discussions/1266#discussioncomment-5073391

----
This is an automatically sent email for issues@kvrocks.apache.org.
To unsubscribe, please send an email to: issues-unsubscribe@kvrocks.apache.org


[GitHub] [kvrocks] git-hulk added a comment to the discussion: Is the mset command atomicity?

Posted by "git-hulk (via GitHub)" <gi...@apache.org>.
GitHub user git-hulk added a comment to the discussion: Is the mset command atomicity?

The MSET command will write key values one by one before PR #1634, so it may cause a partial commit if the server crashed in the middle. But HMSET didn't have this issue since it always writes all fields at once.



GitHub link: https://github.com/apache/kvrocks/discussions/1266#discussioncomment-6743090

----
This is an automatically sent email for issues@kvrocks.apache.org.
To unsubscribe, please send an email to: issues-unsubscribe@kvrocks.apache.org


[GitHub] [kvrocks] ediphy-dwild added a comment to the discussion: Is the mset command atomicity?

Posted by "ediphy-dwild (via GitHub)" <gi...@apache.org>.
GitHub user ediphy-dwild added a comment to the discussion: Is the mset command atomicity?

great. that means that in the absence of failure, writes to hashes are all-or-nothing (ie atomic), which is what we need to match the existing redis behaviour.

where writes to hashes are non-atomic, is in the case of a system failure, i assume?
"It's NOT an atomic operation in MSET command, but we can improve it since we supports multi-key locks now."


GitHub link: https://github.com/apache/kvrocks/discussions/1266#discussioncomment-6742934

----
This is an automatically sent email for issues@kvrocks.apache.org.
To unsubscribe, please send an email to: issues-unsubscribe@kvrocks.apache.org


[GitHub] [kvrocks] ediphy-dwild added a comment to the discussion: Is the mset command atomicity?

Posted by "ediphy-dwild (via GitHub)" <gi...@apache.org>.
GitHub user ediphy-dwild added a comment to the discussion: Is the mset command atomicity?

thanks for the very fast reply! i cant completely parse your answer, im afraid.

are you saying that a reader *can* see a partially constructed hash (really bad, for our use case) or that readers *cannot* see a partially constructed hash (our expected behaviour).

GitHub link: https://github.com/apache/kvrocks/discussions/1266#discussioncomment-6742702

----
This is an automatically sent email for issues@kvrocks.apache.org.
To unsubscribe, please send an email to: issues-unsubscribe@kvrocks.apache.org


[GitHub] [kvrocks] git-hulk edited a comment on the discussion: Is the mset command atomicity?

Posted by "git-hulk (via GitHub)" <gi...@apache.org>.
GitHub user git-hulk edited a comment on the discussion: Is the mset command atomicity?

> can any reader observe the existence of the hash before it is fully constructed?

Unfortunately, it's not, because the reader will always use the snapshot when reading the data to avoid blocking by the write operation.

GitHub link: https://github.com/apache/kvrocks/discussions/1266#discussioncomment-6742669

----
This is an automatically sent email for issues@kvrocks.apache.org.
To unsubscribe, please send an email to: issues-unsubscribe@kvrocks.apache.org