dotnet/orleans · error · ArgumentException

Not all required queries found. Missing are: {string.Join(",

Error message

Not all required queries found. Missing are: {string.Join(",", missingQueryKeys)}

What it means

Thrown by the DbStoredQueries constructor when the supplied queries dictionary is missing one or more keys that correspond to the instance properties compiled in for the current feature (clustering, reminders, persistence, streaming, or grain directory). The message lists exactly which QueryKeys are absent, so the OrleansQuery table or the in-memory dictionary is incomplete.

Source

Thrown at src/AdoNet/Shared/Storage/DbStoredQueries.cs:43

// No default namespace intentionally to cause compile errors if something is not defined
#endif
{
    /// <summary>
    /// This class implements the expected contract between Orleans and the underlying relational storage.
    /// It makes sure all the stored queries are present and 
    /// </summary>
    internal class DbStoredQueries
    {
        private readonly Dictionary<string, string> queries;

        internal DbStoredQueries(Dictionary<string, string> queries)
        {
            var fields = typeof(DbStoredQueries).GetProperties(BindingFlags.Instance | BindingFlags.NonPublic)
                .Select(p => p.Name);
            var missingQueryKeys = fields.Except(queries.Keys).ToArray();
            if (missingQueryKeys.Length > 0)
            {
                throw new ArgumentException(
                    $"Not all required queries found. Missing are: {string.Join(",", missingQueryKeys)}");
            }
            this.queries = queries;
        }

        /// <summary>
        /// The query that's used to get all the stored queries.
        /// this will probably be the same for all relational dbs.
        /// </summary>
        internal const string GetQueriesKey = "SELECT QueryKey, QueryText FROM OrleansQuery";

#if CLUSTERING_ADONET || TESTER_SQLUTILS

        /// <summary>
        /// A query template to retrieve gateway URIs.
        /// </summary>        
        internal string GatewaysQueryKey => queries[nameof(GatewaysQueryKey)];

View on GitHub (pinned to fca799fa70)

Solutions

  1. Run the full Orleans setup script for your database vendor and Orleans version so all OrleansQuery rows exist for every feature you use.
  2. Inspect the exception's missing-keys list and insert those specific QueryKey/QueryText rows into the OrleansQuery table.
  3. Confirm you applied the streaming (or clustering/reminders/persistence/grain-directory) script, not just one of them.

Example fix

-- before: OrleansQuery missing streaming keys
INSERT INTO OrleansQuery (QueryKey, QueryText) VALUES ('GetStreamMessagesKey', 'SELECT ...');
-- add every key listed in the exception message, e.g. QueueStreamMessageKey, ConfirmStreamMessagesKey,
-- FailStreamMessageKey, EvictStreamMessagesKey, EvictStreamDeadLettersKey
Defensive patterns

Strategy: validation

Validate before calling

// After loading queries from OrleansQuery, verify coverage before constructing DbStoredQueries.
var required = typeof(DbStoredQueries).GetProperties(BindingFlags.Instance | BindingFlags.NonPublic).Select(p => p.Name);
var missing = required.Except(loadedQueries.Keys).ToArray();
if (missing.Length > 0)
    throw new InvalidOperationException($"Run the Orleans setup script; missing query keys: {string.Join(",", missing)}");

Prevention

When it happens

Trigger: Constructing DbStoredQueries with a Dictionary<string,string> whose keys do not cover every property name defined under the active #if directive (e.g. STREAMING_ADONET expects QueueStreamMessageKey, GetStreamMessagesKey, ConfirmStreamMessagesKey, FailStreamMessageKey, EvictStreamMessagesKey, EvictStreamDeadLettersKey). The missing keys are reported in the exception message.

Common situations: The OrleansQuery table was seeded with scripts for a different feature set (e.g. clustering scripts applied but streaming used); a partial/older setup script was run; a custom query loader dropped entries; version mismatch where newer Orleans expects additional QueryKeys.

Related errors


AI-assisted analysis of dotnet/orleans@fca799fa70 (2026-08-13). Data as JSON: /api/errors/00e5fef379cfafac. Report an issue: GitHub.