risingwavelabs/risingwave · error · ConnectorError
None is returned by `SELECT sys.fn_cdc_get_max_lsn()`, pleas
Error message
None is returned by `SELECT sys.fn_cdc_get_max_lsn()`, please ensure Sql Server Agent is running.
What it means
The query `SELECT sys.fn_cdc_get_max_lsn()` returned a row but the cell was NULL, i.e. CDC capture jobs have never produced a max LSN. `fn_cdc_get_max_lsn` returns NULL until the SQL Server Agent capture job has populated change tables, so this error points at an environment/agent problem rather than code.
Source
Thrown at src/connector/src/source/cdc/external/sql_server.rs:258
assert_eq!(
bytes.len(),
10,
"sys.fn_cdc_get_max_lsn() should return a 10 bytes array."
);
for byte in &bytes[0..4] {
hex_string.push_str(&format!("{:02x}", byte));
}
hex_string.push(':');
for byte in &bytes[4..8] {
hex_string.push_str(&format!("{:02x}", byte));
}
hex_string.push(':');
for byte in &bytes[8..10] {
hex_string.push_str(&format!("{:02x}", byte));
}
hex_string
}
None => bail!(
"None is returned by `SELECT sys.fn_cdc_get_max_lsn()`, please ensure Sql Server Agent is running."
),
};
tracing::debug!("current max_lsn: {}", max_lsn);
Ok(CdcOffset::SqlServer(SqlServerOffset {
change_lsn: max_lsn,
commit_lsn: MAX_COMMIT_LSN.into(),
}))
}
fn snapshot_read(
&self,
table_name: SchemaTableName,
start_pk: Option<OwnedRow>,
primary_keys: Vec<String>,
limit: u32,View on GitHub (pinned to 6469eb736d)
Solutions
- Start SQL Server Agent: `EXEC master.dbo.xp_servicecontrol N'START', N'SQLServerAGENT'` or start the service on the host/container.
- Check that the CDC capture and cleanup jobs exist and are running (msdb.dbo.cdc_jobs; sqlagent job history).
- Confirm sys.fn_cdc_is_cdc_enabled(DB_ID()) and sys.fn_cdc_has_work_completed return expected values; generate a small change to trigger capture.
- If Agent cannot run (e.g. some editions), consider CDC alternatives (CT/Debezium setup) — RisingWave requires a resolvable max LSN.
Example fix
// before
None => bail!("None is returned by `SELECT sys.fn_cdc_get_max_lsn()`, please ensure Sql Server Agent is running."),
// after (user-side check before starting the source)
-- SELECT sys.fn_cdc_get_max_lsn(); -- must be non-NULL before creating the CDC source Defensive patterns
Strategy: validation
Validate before calling
-- Verify Agent + capture job before starting the source: SELECT sys.fn_cdc_get_max_lsn(); -- must be non-NULL SELECT name, enabled FROM msdb.dbo.cdc_jobs WHERE database_id = DB_ID();
Try / catch
match row.try_get::<&[u8], usize>(0) {
Ok(Some(bytes)) => bytes,
Ok(None) | Err(_) => return Err(anyhow!("max LSN is NULL; start SQL Server Agent and enable CDC")),
} Prevention
- Ensure SQL Server Agent starts automatically (container: enable the agent entrypoint).
- Check cdc_jobs and SQL Agent job history after enabling CDC.
- Generate and capture a test transaction before attaching RisingWave.
When it happens
Trigger: CDC enabled on table metadata but SQL Server Agent not running (common on containers, Linux installs, or localdb), or capture job stopped/failed right after enabling CDC, when `current_cdc_offset` is called to compute the start offset.
Common situations: Docker mssql image without Agent started; Agent license/edition limitations; capture job failing due to missing sysadmin; freshly enabled CDC where no transaction has been captured yet.
Understand the failure class
Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.
Related errors
- SQL Server LSN should be 10 bytes, got {} bytes
- SQL Server max_lsn is NULL
- SQL Server min_lsn is NULL
- No result returned by `SELECT sys.fn_cdc_get_max_lsn()`
- conversion of SQL Server money to {data_type} is not support
AI-assisted analysis of risingwavelabs/risingwave@6469eb736d (2026-09-11).
Data as JSON: /api/errors/6b57c2fde59e3a31.
Report an issue: GitHub.