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

feat(make_idempotent): support making incr request idempotent in pegasus_write_service::impl #2185

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

empiredan
Copy link
Contributor

@empiredan empiredan commented Jan 21, 2025

Implement two APIs making incr request idempotent in pegasus_write_service::impl:

  • translate an incr request (non-idempotent) into a single-put request (idempotent),
    and process the possible errors during the translation, e.g. failed to read base value for
    increment from the RocksDB instance;
  • apply the single-put request into the RocksDB instance and make response for incr.

@empiredan empiredan changed the title feat(make_idempotent): support idempotent incr request in pegasus_write_service::impl feat(make_idempotent): support idempotent incr request in pegasus_write_service::impl Jan 21, 2025
@empiredan empiredan changed the title feat(make_idempotent): support idempotent incr request in pegasus_write_service::impl feat(make_idempotent): support making incr request idempotent in pegasus_write_service::impl Jan 21, 2025
@empiredan empiredan marked this pull request as ready for review January 26, 2025 06:55
return static_cast<int32_t>(get_ctx.expire_ts);
}

if (req.expire_ts_seconds < 0) {
Copy link
Member

Choose a reason for hiding this comment

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

When will expire_ts_seconds to be less than 0?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, -1 means clearing TTL as is described by Java client if ttlSeconds == -1, then update to no ttl if increment succeed. (see https://github.com/apache/incubator-pegasus/blob/master/java-client/src/main/java/org/apache/pegasus/client/PegasusClientInterface.java#L561); and Java client would throw exception once it is less than -1 (see https://github.com/apache/incubator-pegasus/blob/master/java-client/src/main/java/org/apache/pegasus/client/PegasusTable.java#L733).
On server-side, currently non-idempotent incr would also clear TTL once it is less than 0 (see https://github.com/apache/incubator-pegasus/blob/master/src/server/pegasus_write_service_impl.h#L235).

src/server/pegasus_write_service_impl.h Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants