Commit graph

251 commits

Author SHA1 Message Date
artykbasar
2739385184
fix(estimate_count): scope to site db (#35481)
* Fix large-table heuristics: scope estimate_count and guard recency

* fix(estimate_count): scope to site database

Incase some setups don't have per-db-users

Signed-off-by: Akhil Narang <me@akhilnarang.dev>

---------

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
Co-authored-by: artykbasar <artykbasar@users.noreply.github.com>
Co-authored-by: Akhil Narang <me@akhilnarang.dev>
2025-12-29 14:11:34 +05:30
Prafful S
bd4fc118e5
feat: Database SSL one way support (#33044)
* feat: Support one-way SSL authentication for database connections

Updated MariaDB database connection to support one-way SSL authentication

* feat(database): Add support for MySQLClient one-way SSL connections

* feat: Format and pre-commit

* fix: Default option for hostname check

* chore: simplify

Signed-off-by: Akhil Narang <me@akhilnarang.dev>

---------

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
Co-authored-by: Akhil Narang <me@akhilnarang.dev>
2025-07-16 06:36:19 +00:00
Ankush Menat
02ee722e5a
fix: Avoid unnecessary int/long-int migrations (#33109)
Because size wasn't specified it kept syncing over and over again.

Specified default sizes for mariadb.
2025-06-26 12:39:44 +05:30
Ankush Menat
7b8eb5d1b6
feat: MariaDB 11.8 support (#32289)
* ci: Switch to MariaDB 11.8

* ci: Use mariadb's latest client libraries

Co-Authored-By: Sagar Vora <sagar@resilient.tech>

---------

Co-authored-by: Sagar Vora <sagar@resilient.tech>
2025-06-12 10:11:24 +00:00
Ankush Menat
2dfb96f91c
fix: handle snapshot isolation errors better (#32318)
* fix: Avoid Snapshot violation

- Main thread created and "read" user
- Other thread modified something
- Main thread wants to delete or "write" to same row.

This violates snapshot isolation.

* fix: treat snapshot violation as deadlock for now

* test: handle snapshot violations
2025-04-28 06:18:38 +00:00
Ankush Menat
8c0391d085 fix: Define InterfaceError for mariadb 2025-03-19 10:46:23 +05:30
Tarun Pratap Singh
649cf2af66 fix(mysqlclient): set collation in connection 2025-03-18 12:40:25 +05:30
Akhil Narang
4a04b0a17f
Merge pull request #31523 from akhilnarang/set-mariadb-collation
fix(mariadb): set collation in connection
2025-03-17 11:06:27 +00:00
Sagar Vora
521ff071ae perf: compute query type only once 2025-03-15 13:39:57 +05:30
Sagar Vora
b2cab51849
feat: re-introduce mysqlclient 🚀 (#31719)
* feat: mysqlclient

* fix: update error attrs

* fix: decode mogrified query to unicode

* fix: do some cleanup

* chore: disable cleanup for now

* fix: remove unnecessary call to as_unicode

* test: skip perf test for now

* fix: fallback to empty str

* fix: unbuffered cursor support

* fix: update converters and other changes

* fix: add cleanup back

* perf: improve timedelta converter

* fix: dont attempt to run query when explain flag is set

* test: cleanup tests

* chore: remove commented code

* perf: store conf as local var

* chore: ensure sequence

---------

Co-authored-by: Ankush Menat <ankush@frappe.io>
2025-03-15 09:48:21 +05:30
Ankush Menat
573028ad3f
fix: always persist all indexes added via db.add_index (#31177)
* fix: always persist all indexes added via db.add_index

* fix: Add `if not exists` clause for index creation

This allows replica to have same index and master to add it later
without causing SQL error. Just minor DX benefit.

* fix(postgres): don't cache if table doesn't exist

* chore: revert postgres changes

Hopeless to maintain this
2025-02-25 07:25:49 +00:00
Ankush Menat
f90a450bd4
feat: specify row compression for tables (#31361)
Certain tables contain A LOT of duplicate data, it makes sense to enable
compressed row format on them by default. I've seen 5-10 fold reduction
in DB size after enabling compressed format on select few tables.

This has some performance overhead:
- both compressed and uncompressed pages live in buffer pool.
- compression/decompression

Note:
- These cons don't apply much on DocTypes I am enabling this for.
- I am not enabling this on existing sites, migration can take a long
  time! Do it manually with `transform-database` command if you want to.
2025-02-21 09:44:40 +05:30
Brian Pond
00fb8e7a7a
fix: get_table_columns_description() for MariaDB database.py (#28851) 2025-02-11 17:57:52 +05:30
Ankush Menat
ba8cc6f9e4
perf: use client cache for tables (#31102) 2025-02-04 09:30:59 +00:00
Ankush Menat
4406116f86 feat: estimate table size 2025-02-03 09:21:56 +05:30
Brian Pond
61a16f399e
fix: MariaDBDatabase.get_tables() should not query the entire database schema (#28846) 2024-12-22 13:45:23 +05:30
Ankush Menat
54af230131 chore: update tested mariadb versions 2024-12-16 19:02:38 +05:30
Akhil Narang
84ef6ec677
refactor: fixup with ruff 0.8.1
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-12-04 13:18:04 +05:30
Akhil Narang
267e58a819
fix: don't prompt users unless we have a TTY
This can break automated runs (which earlier worked)

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-12-02 20:49:11 +05:30
Akhil Narang
d77abb2663
refactor: allow setting mariadb/postgres specific root credentials in site config
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-12-02 13:24:31 +05:30
Akhil Narang
44128aa62e
refactor: update backup restore failure message
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-10-22 12:49:36 +05:30
Rutwik Hiwalkar
ba2715582b
fix: init db conn for unbuffered cursor if not set (#26220)
* fix: init db conn for unbuffered cursor if not set

* chore: check conn and not cursor

---------

Co-authored-by: Ankush Menat <ankushmenat@gmail.com>
2024-04-30 12:54:12 +00:00
Ankush Menat
c1bf152b89
fix: handle interface error during report timeout (#25893) 2024-04-10 06:57:36 +00:00
Ankush Menat
c14e5cc152
fix: index sort field by default in tabFile (#25853) 2024-04-08 16:28:21 +05:30
Ankush Menat
eef9c2c8cc refactor!: Better Integer handling
- Remove length: it makes no difference, it's for ZEROFILL only.
- Switch to tinyint for checkboxes in mysql and smallint on postgres.
- Use `int` instead of `bigint` by default.
2024-04-06 11:11:29 +05:30
Ankush Menat
a6732a0e12
fix: set db name in filter (#25732) 2024-03-29 16:06:02 +00:00
Ankush Menat
8cc6c31f0e fix: Allow switching between UUID and VARCHAR
- VARCHAR -> UUID = Only allowed when table is empty for now
- UUID -> VARCHAR is not lossy, can be done anytime.
2024-03-29 19:02:28 +05:30
Ankush Menat
6c79a13641 feat: UUID naming support 2024-03-29 19:02:28 +05:30
Akhil Narang
0d3b2499fc
fix: don't use frappe.flags for mariadb_user_host_login_scope
This gets reset whenever we call `frappe.init()` again

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-03-29 16:57:04 +05:30
David
39d4318a27
feat: enable db socket connection 2024-03-29 10:29:50 +01:00
David
6eb1607c0a
refactor: name and explain user host login scope flag for mariadb 2024-03-29 10:26:49 +01:00
Akhil Narang
4b2fde1d8f
fix: check if rollback callback is defined
Don't raise exceptions where a simple print() will suffice
Print exception before prompting for rollback

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-03-29 12:00:25 +05:30
Ankush Menat
3fea2726f3 fix: modified index sync 2024-03-27 23:56:03 +05:30
Ankush Menat
67bcda333e
fix: auto add modified index when sort_field is set to it (#25686)
This is 2nd most common sort order, so we should support adding index
for it automatically.

Not quite sure on generalizing this behaviour *YET*
2024-03-27 14:40:26 +00:00
Ankush Menat
c051c7aba8
fix: keep modified indexed if that's what schema asks for (#25668) 2024-03-27 08:49:49 +00:00
Ankush Menat
432c8cf48c
Merge pull request #25624 from ankush/creation
fix!: Switch to `creation` as default sort order
2024-03-27 13:25:53 +05:30
Ankush Menat
071e269548 fix!: Switch to creation as default sort order 2024-03-27 11:18:28 +05:30
Thatoo
ed01fc3b26
feat: don't require editing MariaDB configuration to setup frappe (#25609)
* feat(db_requirements): Update db_manager.py

* feat(db-requirements): Update setup_db.py

* feat(db-requirements): Update setup_db.py

Don't add error message on top of check_compatible_versions() 's one

Co-authored-by: gavin <gavin18d@gmail.com>

---------

Co-authored-by: gavin <gavin18d@gmail.com>
2024-03-26 18:49:22 +05:30
Ankush Menat
62afa419f8 fix: Add is_virtual in bootstrap schema 2024-03-10 12:19:37 +05:30
Ankush Menat
b60c64cacc
fix: rollback invalid customize form changes (#25198)
* fix: rollback invalid customize form changes

* fix: commit before doing DDL
2024-03-03 17:17:12 +05:30
Shankarv19bcr
437beaa735 fix: typo 2024-02-21 17:19:32 +05:30
Akhil Narang
3f1e19de85
refactor(treewide): enable RUF rules
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-02-21 16:20:28 +05:30
Akhil Narang
26ae0f3460
fix: ruff fixes
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-02-07 17:04:31 +05:30
Ankush Menat
de9ac89748 style: re-format with ruff 2024-02-05 18:53:33 +05:30
Ankush Menat
c02f5d5876
fix: Skip fulltext indexes during sync (#24728)
These are not managed by framework's migration system so we shouldn't
delete them.
2024-02-05 05:30:44 +00:00
David Arnold
b57dbe2dbc
Merge remote-tracking branch 'origin/develop' into chore/cleanup-frappe-connect-2 2024-01-30 10:47:19 +01:00
Akhil Narang
06ed2f5246
fix: allow site creation to work on FC again
FC creates a temporary non-root user to use as the root user here, which doesn't have `SELECT` permissions on `mysql.user`
Try to work around it by relying on `CREATE USER IF NOT EXISTS`

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-01-24 18:50:23 +05:30
David Arnold
94378b6566
chore: simplify frappe.connect and use site config for bootstrapping 2024-01-19 13:49:36 +01:00
David Arnold
7bec22e238
Merge remote-tracking branch 'origin/develop' into chore/cleanup-low-level-db-interface 2024-01-18 13:22:33 +01:00
David Arnold
9a1af12a41
chore: more concise code 2024-01-18 10:20:12 +01:00