Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to delete empty knowledge base #5747

Open
5 tasks done
XiaoLey opened this issue Jun 29, 2024 · 6 comments
Open
5 tasks done

Unable to delete empty knowledge base #5747

XiaoLey opened this issue Jun 29, 2024 · 6 comments
Assignees
Labels
🐞 bug Something isn't working

Comments

@XiaoLey
Copy link
Contributor

XiaoLey commented Jun 29, 2024

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

0.6.12

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

Description:

When attempting to delete an empty knowledge base, I encountered an error that states, "The dataset is being used by some apps. Please remove the dataset from the apps before deleting it." Previously, this knowledge base was associated with some apps, but the associations have since been removed. Despite this, the knowledge base cannot be deleted.

I believe this issue might be a rare occurrence, as I have successfully deleted knowledge bases under similar circumstances in the past.

Snipaste_2024-06-29_19-40-27

  1. Create a new knowledge base.
  2. Associate the knowledge base with some apps.
  3. Remove the associations from the apps.
  4. Ensure the knowledge base is empty.
  5. Try to delete the empty knowledge base.
  6. Observe the error message preventing the deletion.

✔️ Expected Behavior

The empty knowledge base, having no associations with apps, should be deletable without errors.

❌ Actual Behavior

An error message is shown, preventing the deletion of the empty knowledge base as if it is still being used by some apps.

@dosubot dosubot bot added the 🐞 bug Something isn't working label Jun 29, 2024
Copy link

dosubot bot commented Jun 29, 2024

The error message you're encountering, "The dataset is being used by some apps. Please remove the dataset from the apps before deleting it," is likely due to the system still marking the knowledge base as "in use" even after the associations have been removed. This can happen due to stale data in the cache or other internal flags not being updated correctly.

Steps to Troubleshoot and Resolve:

  1. Check for Stale Cache:
    Ensure that the cache related to knowledge base associations is updated. The system might be using stale data, which can be refreshed manually.

  2. Enable Debug Logs:
    Enable debug logs in your Docker deployment to get more detailed information about the deletion process. Follow these steps:

    • Clone the Dify repository:
      git clone https://github.com/langgenius/dify.git
    • Navigate to the Docker directory:
      cd dify/docker
    • Copy the example environment file:
      cp .env.example .env
    • Edit the .env file to enable debug logs by setting the LOG_LEVEL to debug:
      LOG_LEVEL=debug
    • Start Dify with Docker Compose:
      docker compose up -d
    • Access the logs:
      docker compose logs -f
  3. Check Specific Log Entries:
    Look for log entries related to the deletion process, such as:

    [DEBUG] Received request to delete knowledge base with ID: <ID>
    [ERROR] Failed to delete knowledge base with ID: <ID> - <Error Message>
    
  4. Manual Clearing of Associations:
    Use the provided API endpoints to manually clear or reset knowledge base associations. Refer to the Knowledge Base API Documentation for detailed instructions.

  5. Verify and Clear Flags:
    Ensure that there are no specific conditions or flags in the codebase that might cause the knowledge base to be incorrectly marked as "in use." This might involve checking the api/controllers/console/datasets/error.py file for relevant error codes and messages [1].

By following these steps, you should be able to identify and resolve the issue preventing the deletion of the empty knowledge base.

To continue talking to Dosu, mention @dosu.

@JohnJyong
Copy link
Contributor

pls double confirm are there any apps linked this Knowledge
image
@XiaoLey

@XiaoLey
Copy link
Contributor Author

XiaoLey commented Jun 30, 2024

image

@JohnJyong

@kkailaasa
Copy link

facing a similar issue, not able to delete a knowledge base. Getting error saying this knowledge base is associated to an app even though that app has been deleted

@JohnJyong
Copy link
Contributor

it has been opimized by below pr:
#5810
#5787
@kkailaasa @XiaoLey thanks for your feedback

@kkailaasa
Copy link

have pulled the latest docker image, this issue has been fixed, thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants