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

ActiveSqlTransaction: CREATE INDEX CONCURRENTLY cannot run inside a transaction block #2887

Open
4 tasks done
santoshgsk opened this issue Dec 28, 2024 · 1 comment
Open
4 tasks done

Comments

@santoshgsk
Copy link

Checked other resources

  • This is a bug, not a usage question. For questions, please use GitHub Discussions.
  • I added a clear and detailed title that summarizes the issue.
  • I read what a minimal reproducible example is (https://stackoverflow.com/help/minimal-reproducible-example).
  • I included a self-contained, minimal example that demonstrates the issue INCLUDING all the relevant imports. The code run AS IS to reproduce the issue.

Example Code

from psycopg import Connection
from langgraph.store.postgres import PostgresStore

conn_str = f"postgresql://{POSTGRES_USER}:{POSTGRES_PASSWD}@{IP_ADDRESS}:{PORT}/{MEMSTORE_DB}"

conn = Connection.connect(conn_str)

pg_store = PostgresStore(conn=conn)

pg_store.setup()

# Store and retrieve data
pg_store.put(("users", "123"), "prefs", {"theme": "dark"})
item = pg_store.get(("users", "123"), "prefs")

Error Message and Stack Trace (if applicable)

ActiveSqlTransaction                      Traceback (most recent call last)
Cell In[1], line 17
     13 from langgraph.store.postgres import PostgresStore
     15 pg_store = PostgresStore(conn=conn)
---> 17 pg_store.setup()
     19 # Store and retrieve data
     20 pg_store.put(("users", "123"), "prefs", {"theme": "dark"})

File ~/Downloads/Code/venv/lib/python3.11/site-packages/langgraph/store/postgres/base.py:867, in PostgresStore.setup(self)
    865 version = _get_version(cur, table="store_migrations")
    866 for v, sql in enumerate(self.MIGRATIONS[version + 1 :], start=version + 1):
--> 867     cur.execute(sql)
    868     cur.execute("INSERT INTO store_migrations (v) VALUES (%s)", (v,))
    870 if self.index_config:

File ~/Downloads/Code/venv/lib/python3.11/site-packages/psycopg/cursor.py:97, in Cursor.execute(self, query, params, prepare, binary)
     93         self._conn.wait(
     94             self._execute_gen(query, params, prepare=prepare, binary=binary)
     95         )
     96 except e._NO_TRACEBACK as ex:
---> 97     raise ex.with_traceback(None)
     98 return self

ActiveSqlTransaction: CREATE INDEX CONCURRENTLY cannot run inside a transaction block

Description

I am trying to connect to postgresql as a MemoryStore using langgraph store postgres

The connection is established using psycopg - PostgresStore is not taking in the connection string

However, when I am trying to run the .setup() it is showing the error

ActiveSqlTransaction Traceback (most recent call last)
Cell In[1], line 17
13 from langgraph.store.postgres import PostgresStore
15 pg_store = PostgresStore(conn=conn)
---> 17 pg_store.setup()
19 # Store and retrieve data
20 pg_store.put(("users", "123"), "prefs", {"theme": "dark"})

File ~/Downloads/Code/venv/lib/python3.11/site-packages/langgraph/store/postgres/base.py:867, in PostgresStore.setup(self)
865 version = _get_version(cur, table="store_migrations")
866 for v, sql in enumerate(self.MIGRATIONS[version + 1 :], start=version + 1):
--> 867 cur.execute(sql)
868 cur.execute("INSERT INTO store_migrations (v) VALUES (%s)", (v,))
870 if self.index_config:

File ~/Downloads/Code/venv/lib/python3.11/site-packages/psycopg/cursor.py:97, in Cursor.execute(self, query, params, prepare, binary)
93 self._conn.wait(
94 self._execute_gen(query, params, prepare=prepare, binary=binary)
95 )
96 except e._NO_TRACEBACK as ex:
---> 97 raise ex.with_traceback(None)
98 return self

ActiveSqlTransaction: CREATE INDEX CONCURRENTLY cannot run inside a transaction block

Python 3.11

langgraph==0.2.60
langgraph-checkpoint==2.0.9
langgraph-checkpoint-postgres==2.0.9
langgraph-sdk==0.1.48

psycopg==3.2.3
psycopg-c==3.2.3

langchain==0.3.13
langchain-chroma==0.1.4
langchain-community==0.3.7
langchain-core==0.3.28
langchain-experimental==0.3.3
langchain-google-genai==2.0.5
langchain-google-vertexai==2.0.7
langchain-openai==0.2.9
langchain-text-splitters==0.3.4
langchainhub==0.1.15

System Info

Output of "python -m langchain_core.sys_info"

System Information

OS: Darwin
OS Version: Darwin Kernel Version 22.6.0: Wed Jul 5 22:22:05 PDT 2023; root:xnu-8796.141.3~6/RELEASE_ARM64_T6000
Python Version: 3.11.5 (v3.11.5:cce6ba91b3, Aug 24 2023, 10:50:31) [Clang 13.0.0 (clang-1300.0.29.30)]

Package Information

langchain_core: 0.3.28
langchain: 0.3.13
langchain_community: 0.3.7
langsmith: 0.1.144
langchain_chroma: 0.1.4
langchain_experimental: 0.3.3
langchain_google_genai: 2.0.5
langchain_google_vertexai: 2.0.7
langchain_openai: 0.2.9
langchain_text_splitters: 0.3.4
langchainhub: 0.1.15
langgraph_sdk: 0.1.48

Optional packages not installed

langserve

Other Dependencies

aiohttp: 3.10.5
anthropic[vertexai]: Installed. No version info available.
async-timeout: 4.0.3
chromadb: 0.5.20
dataclasses-json: 0.5.14
fastapi: 0.115.5
google-cloud-aiplatform: 1.71.1
google-cloud-storage: 2.18.2
google-generativeai: 0.8.3
httpx: 0.27.0
httpx-sse: 0.4.0
jsonpatch: 1.33
langchain-mistralai: Installed. No version info available.
numpy: 1.25.2
openai: 1.55.0
orjson: 3.10.3
packaging: 24.1
pydantic: 2.9.0
pydantic-settings: 2.6.1
PyYAML: 6.0.2
requests: 2.32.3
requests-toolbelt: 1.0.0
SQLAlchemy: 1.4.53
tenacity: 8.5.0
tiktoken: 0.7.0
types-requests: 2.31.0.20240406
typing-extensions: 4.12.2

@hinthornw
Copy link
Contributor

hinthornw commented Dec 28, 2024

Hello - I'll look into fixing this - I believe it works if you open it in a context manager and/or use a connection pool though

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

2 participants