Class JdbcSandboxExecutionGuard

java.lang.Object
io.agentscope.extensions.mysql.sandbox.JdbcSandboxExecutionGuard
All Implemented Interfaces:
io.agentscope.harness.agent.sandbox.SandboxExecutionGuard

public final class JdbcSandboxExecutionGuard extends Object implements io.agentscope.harness.agent.sandbox.SandboxExecutionGuard
JDBC-backed SandboxExecutionGuard using MySQL GET_LOCK() / RELEASE_LOCK().

Each lock is identified by a string key derived from the SandboxIsolationKey's scope and value. GET_LOCK() blocks until the lock is available or the timeout expires. The lock is tied to the database connection — when the connection closes, the lock is automatically released.

The returned SandboxLease.close() calls RELEASE_LOCK() and closes the underlying connection, ensuring the lock is freed even if the caller forgets to release it.

Important: MySQL named locks are server-scoped, not database-scoped. Use a unique keyPrefix to avoid collisions with other applications sharing the same MySQL server.