Skip to content

feat(opensearch): Formally disable secondary indices in the backend#7541

Merged
acaprau merged 4 commits intomainfrom
andrei/260119/1/opensearch/formally-disable-secondary-indices-backend
Jan 20, 2026
Merged

feat(opensearch): Formally disable secondary indices in the backend#7541
acaprau merged 4 commits intomainfrom
andrei/260119/1/opensearch/formally-disable-secondary-indices-backend

Conversation

@acaprau
Copy link
Copy Markdown
Contributor

@acaprau acaprau commented Jan 19, 2026

Description

We'll re-enable this after the OpenSearch feature work is done.

NOTE: I made some changes since the last review, turns out you cannot just disable all of get_secondary_search_settings and related interactions because by default when we create a fresh instance of Onyx, if the user has not user_has_overridden_embedding_model we automatically create a secondary index for them. This logic is in backend/alembic/versions/dbaa756c2ccf_embedding_models.py.

How Has This Been Tested?

I trust CI.

Additional Options

  • [Optional] Override Linear Check

Summary by cubic

Temporarily disable secondary indices and index swapping across the backend while we finish the OpenSearch work. All flows now use only the primary search settings.

  • Refactors
    • get_secondary_search_settings returns None and logs a warning.
    • Index swapping is disabled: _perform_index_swap raises NotImplementedError; check_and_perform_index_swap logs a warning and returns None.
    • Admin endpoints set_new_search_settings and cancel_new_embedding now return HTTP 501 Not Implemented.
    • Ingestion no longer writes to a secondary index; it indexes only into the primary.
    • Setup avoids secondary settings and notes index swapping is disabled.

Written for commit 610c011. Summary will update on new commits.

@acaprau acaprau requested a review from a team as a code owner January 19, 2026 23:34
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

2 issues found across 5 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="backend/onyx/server/manage/search_settings.py">

<violation number="1" location="backend/onyx/server/manage/search_settings.py:41">
P2: Return an HTTPException with an explicit status/detail instead of raising NotImplementedError, so clients get a clear, intentional response instead of a 500.</violation>

<violation number="2" location="backend/onyx/server/manage/search_settings.py:137">
P2: Return an HTTPException with an explicit status/detail instead of raising NotImplementedError, so clients receive a clear disabled-endpoint response.

(Based on your team's feedback about FastAPI endpoint error handling.) [FEEDBACK_USED]</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Jan 19, 2026

Greptile Summary

Disables secondary index functionality across the backend by hardcoding return values and raising NotImplementedError in key functions. The changes prevent creation of new search settings, index swapping, and secondary index operations during ingestion.

Key changes:

  • get_secondary_search_settings() now returns None with a warning log
  • Index swap functions (check_and_perform_index_swap(), _perform_index_swap()) raise NotImplementedError
  • API endpoints for setting/canceling new embeddings raise NotImplementedError
  • Secondary index handling in ingestion is commented out
  • setup.py hardcodes secondary_search_settings = None but doesn't fully clean up usage sites

The approach is consistent with temporary feature disabling, allowing easy re-enablement by uncommenting code. However, in setup.py:82, the code violates the custom instruction about hardcoded constants - the variable should be removed entirely and all usage sites cleaned up.

Confidence Score: 4/5

  • Safe to merge with minor style improvements recommended
  • The changes effectively disable secondary index functionality as intended. The implementation is straightforward with clear TODO comments for re-enablement. One style violation exists where secondary_search_settings is hardcoded to None but still used in multiple places rather than being fully cleaned up per coding standards. This doesn't affect functionality since the conditional checks will correctly evaluate to False, but violates the stated custom instruction for cleaner code.
  • backend/onyx/setup.py could benefit from cleaning up the hardcoded secondary_search_settings variable per the custom instruction

Important Files Changed

Filename Overview
backend/onyx/db/search_settings.py Disabled secondary search settings by hardcoding return value to None with warning log
backend/onyx/db/swap_index.py Disabled index swapping functions by raising NotImplementedError and adding warning logs
backend/onyx/server/manage/search_settings.py Disabled setting and canceling new search settings endpoints by raising NotImplementedError
backend/onyx/server/onyx_api/ingestion.py Commented out secondary index handling in ingestion endpoint
backend/onyx/setup.py Hardcoded secondary_search_settings to None but still uses it in conditional checks and function calls

Sequence Diagram

sequenceDiagram
    participant Client
    participant API
    participant SearchSettings
    participant SwapIndex
    participant Setup
    participant DocIndex

    Note over Client,DocIndex: Secondary Index Disabled Flow

    Client->>API: POST /set-new-search-settings
    API->>API: Raise NotImplementedError
    API-->>Client: Error: "Setting new search settings is temporarily disabled"

    Client->>API: POST /cancel-new-embedding
    API->>API: Raise NotImplementedError
    API-->>Client: Error: "Cancelling new embedding is temporarily disabled"

    Note over Setup,DocIndex: On Startup/Setup

    Setup->>SwapIndex: check_and_perform_index_swap()
    SwapIndex->>SwapIndex: Log warning
    SwapIndex-->>Setup: Return None (no swap)

    Setup->>SearchSettings: get_active_search_settings()
    SearchSettings->>SearchSettings: get_secondary_search_settings()
    SearchSettings->>SearchSettings: Log warning
    SearchSettings-->>SearchSettings: Return None
    SearchSettings-->>Setup: ActiveSearchSettings(primary, secondary=None)

    Setup->>Setup: Hardcode secondary_search_settings = None
    Setup->>DocIndex: get_default_document_index(primary, None)
    DocIndex-->>Setup: Document index initialized

    Note over Client,DocIndex: Ingestion Flow

    Client->>API: POST /upsert-document
    API->>API: Check active_search_settings.secondary
    API->>API: Skip secondary indexing (commented out)
    API-->>Client: Success (only primary index updated)
Loading

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

5 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

secondary_search_settings = active_search_settings.secondary
# TODO(andrei): Re-enable this bit.
# secondary_search_settings = active_search_settings.secondary
secondary_search_settings: SearchSettings | None = None
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

style: Hardcoding secondary_search_settings to None violates the custom instruction to remove the variable entirely when hardcoding to a constant. The variable is still used on lines 94, 141, and 148-149. Consider removing the variable and cleaning up all usage sites:

  • Line 94: The condition if secondary_search_settings and DISABLE_INDEX_UPDATE_ON_SWAP: will always be False, so remove the entire block
  • Line 141: Pass None directly to get_default_document_index()
  • Lines 148-149: Simplify to just None
Suggested change
secondary_search_settings: SearchSettings | None = None
# TODO(andrei): Re-enable this bit.
# secondary_search_settings = active_search_settings.secondary

Context Used: Rule from dashboard - When hardcoding a boolean variable to a constant value, remove the variable entirely and clean up al... (source)

Prompt To Fix With AI
This is a comment left during a code review.
Path: backend/onyx/setup.py
Line: 82:82

Comment:
**style:** Hardcoding `secondary_search_settings` to `None` violates the custom instruction to remove the variable entirely when hardcoding to a constant. The variable is still used on lines 94, 141, and 148-149. Consider removing the variable and cleaning up all usage sites:

- Line 94: The condition `if secondary_search_settings and DISABLE_INDEX_UPDATE_ON_SWAP:` will always be `False`, so remove the entire block
- Line 141: Pass `None` directly to `get_default_document_index()`
- Lines 148-149: Simplify to just `None`

```suggestion
    # TODO(andrei): Re-enable this bit.
    # secondary_search_settings = active_search_settings.secondary
```

**Context Used:** Rule from `dashboard` - When hardcoding a boolean variable to a constant value, remove the variable entirely and clean up al... ([source](https://app.greptile.com/review/custom-context?memory=17793125-da1f-469f-ae44-062cf6bd177e))

How can I resolve this? If you propose a fix, please make it concise.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

that's too much work

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

3 issues found across 5 files (changes from recent commits).

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="backend/onyx/db/swap_index.py">

<violation number="1">
P1: Search settings are marked swapped before the Vespa index swap succeeds. If ensure_indices_exist fails, the function returns None but the DB status is already PAST/PRESENT, leaving the system in an inconsistent state. Update statuses only after the swap succeeds (or roll back on failure).</violation>
</file>

<file name="backend/onyx/db/search_settings.py">

<violation number="1">
P2: get_secondary_search_settings now returns the latest FUTURE settings, which re-enables secondary index handling via get_active_search_settings. If secondary indices are meant to be disabled, this should return None (and optionally log a warning) instead of querying the DB.</violation>
</file>

<file name="backend/onyx/server/onyx_api/ingestion.py">

<violation number="1">
P2: This block re-enables secondary indexing for ingestion, which contradicts the stated goal of disabling secondary indices. If a secondary search setting exists, ingestion will still write to it. Consider skipping secondary indexing entirely while the feature is disabled.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@acaprau acaprau enabled auto-merge January 20, 2026 17:23
@acaprau acaprau added this pull request to the merge queue Jan 20, 2026
Merged via the queue into main with commit d88a417 Jan 20, 2026
134 of 137 checks passed
@acaprau acaprau deleted the andrei/260119/1/opensearch/formally-disable-secondary-indices-backend branch January 20, 2026 18:25
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