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

UNIQUE constraint failed: sections.indexid #706

Open
obonyojimmy opened this issue May 2, 2024 · 1 comment
Open

UNIQUE constraint failed: sections.indexid #706

obonyojimmy opened this issue May 2, 2024 · 1 comment

Comments

@obonyojimmy
Copy link

obonyojimmy commented May 2, 2024

Trying to upsert multiple rows to an embeding instance , it sometimes errors out with

UNIQUE constraint failed: sections.indexid

After which no rows get upserted afterwards. How can we mitigate this.Thank you.
Heres a sniplet of the error log:

File "/app/taskflow/artifacts/artifact.py", line 578, in add
taskflow-1  |     self.embeddings.upsert(stream(data_inputs))
taskflow-1  |   File "/root/.local/lib/python3.10/site-packages/txtai/embeddings/base.py", line 174, in upsert
taskflow-1  |     ids, _, embeddings = transform(stream(documents), buffer)
taskflow-1  |   File "/root/.local/lib/python3.10/site-packages/txtai/embeddings/index/transform.py", line 76, in __call__
taskflow-1  |     ids, dimensions, embeddings = self.vectors(documents, buffer)
taskflow-1  |   File "/root/.local/lib/python3.10/site-packages/txtai/embeddings/index/transform.py", line 95, in vectors
taskflow-1  |     ids, dimensions, batches, stream = self.model.index(self.stream(documents), self.batch)
taskflow-1  |   File "/root/.local/lib/python3.10/site-packages/txtai/vectors/base.py", line 96, in index
taskflow-1  |     for document in documents:
taskflow-1  |   File "/root/.local/lib/python3.10/site-packages/txtai/embeddings/index/transform.py", line 183, in stream
taskflow-1  |     self.load(batch, offset)
taskflow-1  |   File "/root/.local/lib/python3.10/site-packages/txtai/embeddings/index/transform.py", line 208, in load
taskflow-1  |     self.database.insert(batch, self.offset)
taskflow-1  |   File "/root/.local/lib/python3.10/site-packages/txtai/database/rdbms.py", line 66, in insert
taskflow-1  |     self.loadsection(index, uid, document, tags, entry)
taskflow-1  |   File "/root/.local/lib/python3.10/site-packages/txtai/database/rdbms.py", line 361, in loadsection
taskflow-1  |     self.insertsection(index, uid, text, tags, entry)
taskflow-1  |   File "/root/.local/lib/python3.10/site-packages/txtai/database/rdbms.py", line 376, in insertsection
taskflow-1  |     self.cursor.execute(Statement.INSERT_SECTION, [index, uid, text, tags, entry])
taskflow-1  | sqlite3.IntegrityError: UNIQUE constraint failed: sections.indexid
@obonyojimmy
Copy link
Author

not sure but i think we could let sections table collumn, indexId be auto-incremental and have load_section() , insert without the offset count value provided .

from :

        CREATE TABLE IF NOT EXISTS %s (
            indexid INTEGER PRIMARY KEY,
            id TEXT,
            text TEXT,
            tags TEXT,
            entry DATETIME
        )
    """

to:

 CREATE_SECTIONS = """
        CREATE TABLE IF NOT EXISTS %s (
            indexid INTEGER PRIMARY KEY AUTOINCREMENT,
            id TEXT,
            text TEXT,
            tags TEXT,
            entry DATETIME
        )
    """

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

No branches or pull requests

1 participant