Skip to content

Conversation

MasterPtato
Copy link
Contributor

No description provided.

Copy link

vercel bot commented Oct 2, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
rivet-cloud Ready Ready Preview Comment Oct 8, 2025 7:05am
2 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
rivet-inspector Ignored Ignored Preview Oct 8, 2025 7:05am
rivet-site Ignored Ignored Preview Oct 8, 2025 7:05am

Copy link

claude bot commented Oct 2, 2025

Claude encountered an error —— View job


I'll analyze this and get back to you.

Copy link
Contributor Author

MasterPtato commented Oct 2, 2025


How to use the Graphite Merge Queue

Add the label merge-queue to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

Copy link

pkg-pr-new bot commented Oct 2, 2025

Open in StackBlitz

npm i https://pkg.pr.new/rivet-dev/engine/@rivetkit/engine-runner@3035
npm i https://pkg.pr.new/rivet-dev/engine/@rivetkit/engine-runner-protocol@3035

commit: 60a09d5

Copy link

claude bot commented Oct 2, 2025

Claude encountered an error —— View job


I'll analyze this and get back to you.

Copy link

claude bot commented Oct 2, 2025

Claude encountered an error —— View job


I'll analyze this and get back to you.

@MasterPtato MasterPtato mentioned this pull request Oct 2, 2025
@MasterPtato MasterPtato marked this pull request as ready for review October 2, 2025 22:01
if self.committed.load(Ordering::SeqCst) {
return Ok(());
}
self.committed.store(true, Ordering::SeqCst);
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider moving the committed.store(true, Ordering::SeqCst) line after the successful commit operation to prevent a potential race condition. If the commit fails, the transaction would be incorrectly marked as committed, which could lead to unexpected behavior in error recovery scenarios.

Spotted by Diamond

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

Copy link

claude bot commented Oct 3, 2025

Claude encountered an error —— View job


I'll analyze this and get back to you.

@MasterPtato MasterPtato force-pushed the 10-01-fix_udb_fix_postgres_driver_impl branch from 8e04f9c to b9aa0d1 Compare October 3, 2025 23:40
Copy link

claude bot commented Oct 3, 2025

Claude encountered an error —— View job


I'll analyze this and get back to you.

Copy link

claude bot commented Oct 7, 2025

Claude encountered an error —— View job


I'll analyze this and get back to you.

Copy link

claude bot commented Oct 7, 2025

Claude encountered an error —— View job


I'll analyze this and get back to you.

Copy link
Contributor

graphite-app bot commented Oct 8, 2025

Merge activity

  • Oct 8, 6:30 AM UTC: NathanFlurry added this pull request to the Graphite merge queue.
  • Oct 8, 6:31 AM UTC: The Graphite merge queue couldn't merge this PR because it had merge conflicts.
  • Oct 8, 6:31 AM UTC: NathanFlurry added this pull request to the Graphite merge queue.
  • Oct 8, 6:32 AM UTC: The Graphite merge queue couldn't merge this PR because it had merge conflicts.
  • Oct 8, 6:56 AM UTC: NathanFlurry added this pull request to the Graphite merge queue.
  • Oct 8, 6:57 AM UTC: CI is running for this pull request on a draft pull request (#3121) due to your merge queue CI optimization settings.
  • Oct 8, 6:58 AM UTC: Merged by the Graphite merge queue via draft PR: #3121.

@NathanFlurry NathanFlurry force-pushed the 10-01-fix_udb_fix_postgres_driver_impl branch from ea5bccd to 60a09d5 Compare October 8, 2025 06:55
Copy link

claude bot commented Oct 8, 2025

Claude encountered an error —— View job


I'll analyze this and get back to you.

graphite-app bot pushed a commit that referenced this pull request Oct 8, 2025
@graphite-app graphite-app bot closed this Oct 8, 2025
Comment on lines +220 to +272
async fn handle_get_range(
&mut self,
tx: &Transaction<'_>,
begin_key: Vec<u8>,
begin_or_equal: bool,
begin_offset: i32,
end_key: Vec<u8>,
end_or_equal: bool,
end_offset: i32,
limit: Option<usize>,
reverse: bool,
) -> Result<Values> {
// Determine SQL operators based on key selector types
// For begin selector:
// first_greater_or_equal: or_equal = false, offset = 1 -> ">="
// first_greater_than: or_equal = true, offset = 1 -> ">"
let begin_op = if begin_offset == 1 {
if begin_or_equal { ">" } else { ">=" }
} else {
// This shouldn't happen for begin in range queries
">="
};

// For end selector:
// first_greater_than: or_equal = true, offset = 1 -> "<="
// first_greater_or_equal: or_equal = false, offset = 1 -> "<"
let end_op = if end_offset == 1 {
if end_or_equal { "<=" } else { "<" }
} else {
// This shouldn't happen for end in range queries
"<"
};

// Build query with CTE that adds conflict range
let query = if reverse {
if let Some(limit) = limit {
format!(
"SELECT key, value FROM kv WHERE key {begin_op} $1 AND key {end_op} $2 ORDER BY key DESC LIMIT {limit}"
)
} else {
format!(
"SELECT key, value FROM kv WHERE key {begin_op} $1 AND key {end_op} $2 ORDER BY key DESC"
)
}
} else if let Some(limit) = limit {
format!(
"SELECT key, value FROM kv WHERE key {begin_op} $1 AND key {end_op} $2 ORDER BY key LIMIT {limit}"
)
} else {
format!(
"SELECT key, value FROM kv WHERE key {begin_op} $1 AND key {end_op} $2 ORDER BY key"
)
};
Copy link
Contributor

Choose a reason for hiding this comment

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

The PostgreSQL implementation of handle_get_range doesn't add conflict ranges for read operations, unlike the RocksDB implementation. This inconsistency could lead to transaction anomalies when using serializable isolation. Consider adding code to insert conflict ranges for range reads, similar to how it's done in the RocksDB driver:

// Add read conflict range for this range
if let IsolationLevel::Serializable = isolation_level {
    // Insert conflict range for the read operation
    let query = "INSERT INTO conflict_ranges (range_data, conflict_type, start_version, commit_version) 
                 VALUES (bytearange($1, $2, '[)'), 'read', $3, $4)";
    // Execute with appropriate parameters
}

This would ensure consistent behavior between database backends and proper serializable isolation semantics.

Suggested change
async fn handle_get_range(
&mut self,
tx: &Transaction<'_>,
begin_key: Vec<u8>,
begin_or_equal: bool,
begin_offset: i32,
end_key: Vec<u8>,
end_or_equal: bool,
end_offset: i32,
limit: Option<usize>,
reverse: bool,
) -> Result<Values> {
// Determine SQL operators based on key selector types
// For begin selector:
// first_greater_or_equal: or_equal = false, offset = 1 -> ">="
// first_greater_than: or_equal = true, offset = 1 -> ">"
let begin_op = if begin_offset == 1 {
if begin_or_equal { ">" } else { ">=" }
} else {
// This shouldn't happen for begin in range queries
">="
};
// For end selector:
// first_greater_than: or_equal = true, offset = 1 -> "<="
// first_greater_or_equal: or_equal = false, offset = 1 -> "<"
let end_op = if end_offset == 1 {
if end_or_equal { "<=" } else { "<" }
} else {
// This shouldn't happen for end in range queries
"<"
};
// Build query with CTE that adds conflict range
let query = if reverse {
if let Some(limit) = limit {
format!(
"SELECT key, value FROM kv WHERE key {begin_op} $1 AND key {end_op} $2 ORDER BY key DESC LIMIT {limit}"
)
} else {
format!(
"SELECT key, value FROM kv WHERE key {begin_op} $1 AND key {end_op} $2 ORDER BY key DESC"
)
}
} else if let Some(limit) = limit {
format!(
"SELECT key, value FROM kv WHERE key {begin_op} $1 AND key {end_op} $2 ORDER BY key LIMIT {limit}"
)
} else {
format!(
"SELECT key, value FROM kv WHERE key {begin_op} $1 AND key {end_op} $2 ORDER BY key"
)
};
async fn handle_get_range(
&mut self,
tx: &Transaction<'_>,
begin_key: Vec<u8>,
begin_or_equal: bool,
begin_offset: i32,
end_key: Vec<u8>,
end_or_equal: bool,
end_offset: i32,
limit: Option<usize>,
reverse: bool,
) -> Result<Values> {
// Determine SQL operators based on key selector types
// For begin selector:
// first_greater_or_equal: or_equal = false, offset = 1 -> ">="
// first_greater_than: or_equal = true, offset = 1 -> ">"
let begin_op = if begin_offset == 1 {
if begin_or_equal { ">" } else { ">=" }
} else {
// This shouldn't happen for begin in range queries
">="
};
// For end selector:
// first_greater_than: or_equal = true, offset = 1 -> "<="
// first_greater_or_equal: or_equal = false, offset = 1 -> "<"
let end_op = if end_offset == 1 {
if end_or_equal { "<=" } else { "<" }
} else {
// This shouldn't happen for end in range queries
"<"
};
// Add read conflict range for this range if using serializable isolation
if let IsolationLevel::Serializable = self.isolation_level {
let conflict_query = "INSERT INTO conflict_ranges (range_data, conflict_type, start_version, commit_version)
VALUES (bytearange($1, $2, '[)'), 'read', $3, $4)";
tx.execute(
conflict_query,
&[&begin_key, &end_key, &self.start_version, &self.commit_version],
)
.await
.map_err(|e| Error::DatabaseError(e.to_string()))?;
}
// Build query with CTE that adds conflict range
let query = if reverse {
if let Some(limit) = limit {
format!(
"SELECT key, value FROM kv WHERE key {begin_op} $1 AND key {end_op} $2 ORDER BY key DESC LIMIT {limit}"
)
} else {
format!(
"SELECT key, value FROM kv WHERE key {begin_op} $1 AND key {end_op} $2 ORDER BY key DESC"
)
}
} else if let Some(limit) = limit {
format!(
"SELECT key, value FROM kv WHERE key {begin_op} $1 AND key {end_op} $2 ORDER BY key LIMIT {limit}"
)
} else {
format!(
"SELECT key, value FROM kv WHERE key {begin_op} $1 AND key {end_op} $2 ORDER BY key"
)
};

Spotted by Diamond

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

@graphite-app graphite-app bot deleted the 10-01-fix_udb_fix_postgres_driver_impl branch October 8, 2025 06:58
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