aboutsummaryrefslogtreecommitdiffstats
path: root/includes/libs/rdbms/database
Commit message (Collapse)AuthorAgeFilesLines
* libs: Use type declaration on undocumented private functionsUmherirrender2025-03-313-3/+5
| | | | Change-Id: I9a74c316b87ae35597ce846a830a55542d9aa14c
* rdbms: Fix disabled PostgreSQL testTim Starling2025-03-241-13/+17
| | | | | | | | | | | | | | | | | | | And clean up after version requirement was increased to PG 10. * In DatabasePostgres::indexInfo() iterate over all core schemas instead of just querying the current schema. I broke this after the test for it was disabled. * In ApiQueryAllPages, remove the PG 9 branches and simplify the comments. * In DatabasePostgresTest, fix the skip conditions for the introduction of DBConnRef. * Remove tests for "old insert ignore", and "old insert select", which no longer exist. * In testFieldAndIndexInfo(), create a prefixed table name since that's easier and safer than trying to switch domains just for this test. Bug: T259084 Change-Id: Ifab7c045c40d039e542e2df19037b342d4984472
* rdbms: Don't forward DB connection handle to transaction callbacksMáté Szabó2025-02-123-12/+6
| | | | | | | | | | | | | | | | | | | | | | | | Why: - When a transaction lifecycle callback such as onTransactionPreCommitOrIdle() is invoked by rdbms, rdbms passes in the DB connection handle the callback was scheduled on. - However, the DB connection handle may have since been reset to a different DB domain on the same physical cluster due to connection reuse. - We could implement bookkeeping to keep track of the expected DB domain for each pending callback and ensure the passed-in DB handle matches that before invoking the callback, but nobody seems to be making use of the passed-in DB handle except for two call sites in core. - As such, it seems more prudent to remove this functionality. What: - Stop passing the DB connection handle to rdbms transaction lifecycle callbacks. Bug: T386190 Change-Id: I9125bfb8b5e2cac4aab3525ffd229ea49beccc17
* Merge "libs: Replace call_user_func with dynamic function call"jenkins-bot2025-02-083-4/+4
|\
| * libs: Replace call_user_func with dynamic function callUmherirrender2025-01-313-4/+4
| | | | | | | | | | | | | | | | Use modern php syntax to call a callable. Reduce the stack trace to improve performance and better IDE and static analyzer support Change-Id: I8e563140ac3465ce3b3f8ec5e01bfd493c7269fe
* | Replace func_get_args() with real variadic argument in DatabaseUmherirrender2025-02-061-1/+1
| | | | | | | | Change-Id: I8478a7b5f6a53ddb648ead6eabb7015c1f2a33c8
* | build: Updating mediawiki/mediawiki-codesniffer to 46.0.0libraryupgrader2025-01-311-1/+1
|/ | | | Change-Id: I0f8a8cac36015bba52aea3ee2affd92f83d3574a
* Remove 2-line PHPDocs that just repeat the types from the codethiemowmde2025-01-173-24/+0
| | | | | | | | | | | | | | | | Same as Ia294bf4 did for 1-line comments. This patch removes slightly more complex 2-line PHPDoc comments that don't add any new information to the code, but literally repeat what the code already says. They say "don't document the code, code the documentation", and we are doing this more and more. We just tend to forget to remove the obsolete comments. Note I'm also removing a line of text in a few cases when it's very short and literally says the same as the method name. Again, such comments add zero new information. Change-Id: I01535404bab458c6c47e48e5456403b7a64198ed
* Remove trivial 1-line PHPDocs that just repeat the codethiemowmde2025-01-162-9/+0
| | | | | | | | | | | | | I assume these are all either auto-generated by an IDE or the language-level type declarations have been added later. In any case the comments don't add any new information to what the code already says. This is just extra clutter that makes the code harder to read, I would argue. There are many, many more comments like this. In this patch I intentionally focus on the most trivial 1-line comments. Change-Id: Ia294bf4ce0d8a77036842fe25884bc175c2b0e7d
* Merge "rdbms: simplify transaction round flag handling in LoadBalancer"jenkins-bot2025-01-101-0/+5
|\
| * rdbms: simplify transaction round flag handling in LoadBalancerAaron Schulz2024-12-191-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | Merged the (apply|undo)TransactionRoundFlags() methods into a single syncConnectionRoundState() method. Avoid the use of REMEMBER_PRIOR, which carried some risk of the flags and round state getting out of sync during failure/recovery. Add LB_TRX_ROUND_LEVEL for tracking transaction rounds, even when they are implicit. Change-Id: I77ffcf4814adee4e1d9bb0897cd22427465e33ed
* | Database: tracing: emit row respose statsChris Danis2025-01-071-0/+7
| | | | | | | | | | Bug: T340552 Change-Id: I4e480e01ada308f15304630d8caa6921418cd4c6
* | Database: tracing: query errors => span errorChris Danis2025-01-071-1/+3
| | | | | | | | | | Bug: T340552 Change-Id: Ie44ebc11d62ba71542ea8f7055be65df06468227
* | Database: prefix tracing operation namesChris Danis2025-01-061-2/+2
| | | | | | | | | | | | | | | | | | Why: Sometimes the verb will be something really generic like BEGIN. https://phabricator.wikimedia.org/F58134893 Bug: T340552 Change-Id: I60dcc1cda332d4d64fb66b084bb7da582e7d1a3f
* | rdbms/Database: cleanup otel attributesChris Danis2025-01-031-4/+1
| | | | | | | | Change-Id: I484ce9391511a395ffeed4e4084d34f4c12cb8bd
* | Rdbms\Database: export OTel spans for db operationsChris Danis2024-12-202-0/+42
| | | | | | | | | | Bug: T340552 Change-Id: I7896f6ebee151d7da1d88e04bb4d05dc007d67e8
* | Merge "rdbms: remove MWLBFactory::applyGlobalState deferred update logic"jenkins-bot2024-12-201-0/+1
|\ \ | |/ |/|
| * rdbms: remove MWLBFactory::applyGlobalState deferred update logicAaron Schulz2024-12-191-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Make the Maintenance transaction wrapper methods directly invoke DeferredUpdates::tryOpportunisticExecute() and flush stats data. This includes the following methods: * Maintenance::commitTransaction() * Maintenance::commitTransactionRound() * Maintenance::waitForReplication() Add explicit DeferredUpdates::tryOpportunisticExecute() calls to integration tests as needed. Deprecate the now-unused IDatabase::setTransactionListener() and ILBFactory::setWaitForReplicationListener(). Bug: T373057 Change-Id: I06488d1826ee97de460cf52117b5d691fa5945ad
* | Replace isset() with null checksUmherirrender2024-12-191-2/+2
|/ | | | | | | | | isset() should only be used to suppress errors, not for null check. When the property is always defined, there is no need to use isset. Found by a new phan plugin (2efea9f989) https://www.mediawiki.org/wiki/Manual:Coding_conventions/PHP#isset Change-Id: Ib84b7d71e8308a36409f30ecfd16e9de149e97b3
* Merge "rdbms: Tighten PHPCS LineLength disables"jenkins-bot2024-12-172-6/+13
|\
| * rdbms: Tighten PHPCS LineLength disablesBartosz Dziewoński2024-11-032-6/+13
| | | | | | | | | | | | | | I recently learned about this way to disable PHPCS checks within a block comment, we use it in some other places. Change-Id: Ibac8be95cd6a479481b20c7a2653800d6252dfb7
* | rdbms: renamed $trxRoundId parameters in TransactionManagerAaron Schulz2024-12-023-8/+8
| | | | | | | | | | | | | | | | Use strict comparisons with getTransactionRoundFname() return values. Update some LB_* constant comments. Change-Id: I5401af02e2b302be0f73864f9d53f6b4d29b65b1
* | rdbms: rename LBFactory/LoadBalancer trxRoundId field to trxRoundFnameAaron Schulz2024-12-022-11/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These are not IDs and the name was inconsistent with actual ID fields in things like TransactionManager. Rename IDatabase::LB_TRX_ROUND_ID constant to LB_TRX_ROUND_FNAME and Database::getTransactionRoundID() to getTransactionRoundFname(). Also, make the trxRoundFname field string|null instead of the less standard string|false style. This now matches TransactionManager and Database::getTransactionRoundFname() and allows for simplification of the later. Also mark the IDatabase::LB_* constants internal. Change-Id: I8f98624b4aea3402093f65e12d89dc14a01eab3c
* | rdbms: Remove ISQLPlatform::tableNames()Aaron Schulz2024-11-221-4/+0
| | | | | | | | | | | | | | Deprecated in Iaee516dc25c50f8c4. Bug: T373655 Change-Id: I025c0983bc85617682214a57fe41cb363713cbab
* | rdbms: Remove handling of cancel callbacksAmir Sarabadani2024-11-144-107/+5
|/ | | | | | | | | | These cancel callbacks are not used at all. It is adding a lot of complexity to the transaction management of rdbms making it quite harder to understand and reason about. Bug: T363839 Change-Id: I3cb1e30611b83c03535ea87a216bbedd4a911f4e
* Merge "Use ++ and -- rather than += 1 and -= 1"jenkins-bot2024-10-231-2/+2
|\
| * Use ++ and -- rather than += 1 and -= 1Reedy2024-10-171-2/+2
| | | | | | | | Change-Id: I27b9a19ab952ede1267921bd042af0fe1c89e228
* | Merge "rdbms: clean up use of GeneralizedSql in Database::attemptQuery()"jenkins-bot2024-10-222-12/+25
|\ \
| * | rdbms: clean up use of GeneralizedSql in Database::attemptQuery()Aaron Schulz2024-10-222-12/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Always create a GeneralizedSQL instance for the profiling callback and TransactionProfiler. This cuts down on the duck type checking. Fix bug where the "role-primary" prefix was missing if the clean SQL was set for the Query instance. This change adds a GeneralizedSql::newFromQuery() helper method. Change-Id: Ib05f7693ac81ad88248ce69a22094aecb4bf7842
* | | Merge "rdbms: clean up lastPrimaryChangeTimestamp() and lastDoneWrites()"jenkins-bot2024-10-222-6/+9
|\| |
| * | rdbms: clean up lastPrimaryChangeTimestamp() and lastDoneWrites()Aaron Schulz2024-09-252-6/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Only count writes that were committed (including auto-committed). There are already methods like writesPending() for checking for pending writes and the timestamp that pending writes where issued is not useful. The write commit timestamp is what matters. These methods are used by waitForReplication(), which should not try to wait for pending changes to replicate, since they have to be committed first. Mark these methods as @internal and use null return values instead of false. Change-Id: If1a9a21637d6e5ba3643c77cbc8bc6459f8aa882
* | | Merge "rdbms: Remove reliance on internal STATUS_TRX and STATUS_SESS_ sequence"jenkins-bot2024-10-222-6/+6
|\ \ \ | |_|/ |/| |
| * | rdbms: Remove reliance on internal STATUS_TRX and STATUS_SESS_ sequenceTimo Tijhof2024-10-222-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Follows-up I39cee1363496dfe2, which added a condition based on `status > ERROR` which I think requires a reliance on, and understanding/remembering of, the numerical sequence of statuses. This sequence appears undocumented, both in the TransactionManager constants and the trxStatus/sessionStatus methods, but either way is not needed in any of the current cases. This made the code harder to understand, increases doubt about its correctness, requiring additional checking while debugging or code reviewing. Change-Id: Ia0f4b0cfae02de52e7618e558cca6d266689e760
* | | Use explicit nullable type on parameter argumentsUmherirrender2024-10-167-30/+30
|/ / | | | | | | | | | | | | | | | | | | | | Implicitly marking parameter $... as nullable is deprecated in php8.4, the explicit nullable type must be used instead Created with autofix from Ide15839e98a6229c22584d1c1c88c690982e1d7a Break one long line in SpecialPage.php Bug: T376276 Change-Id: I807257b2ba1ab2744ab74d9572c9c3d3ac2a968e
* | rdbms: avoid pcre.backtrack_limit in QueryBuilderFromRawSql::generalizeSQL()Aaron Schulz2024-10-011-1/+1
| | | | | | | | | | | | | | Add some unit tests for this method. Bug: T366640 Change-Id: I466c83a8d2b8fabcd4c30eb079273dfd52a31b71
* | Merge "rdbms: improve Database::flushSnapshot() to use ROLLBACK sometimes"jenkins-bot2024-10-011-6/+14
|\ \
| * | rdbms: improve Database::flushSnapshot() to use ROLLBACK sometimesAaron Schulz2024-09-271-6/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | In case a DB handle ends up in STATUS_TRX_ERROR, use "ROLLBACK" so that assertQueryIsCurrentlyAllowed() does not complain. Also improved related Database::assessConnectionLoss() comments. Change-Id: I39cee1363496dfe29e268a219b39070b23fdee4c
* | | Merge "Add @phan-mandatory-param for function name arguments"jenkins-bot2024-09-305-39/+39
|\ \ \
| * | | Add @phan-mandatory-param for function name argumentsUmherirrender2024-09-205-39/+39
| | |/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | Providing the function name is often optional from the php code, but it is needed for better logging, so make it mandatory and let phan report issues about this. Bug: T374546 Depends-On: Iaed5489a85a5a6e685829e151436afc94310fbd0 Depends-On: Ie2a1e5052e5b61bbb5b89905de942f47d3f1413d Change-Id: I5227f2fa65850ac8c6f620900f22d1f4e7bfd470
* | | Merge "rdbms: Remove fallback function name from internal functions"jenkins-bot2024-09-304-7/+7
|\ \ \ | |_|/ |/| |
| * | rdbms: Remove fallback function name from internal functionsUmherirrender2024-09-244-7/+7
| |/ | | | | | | | | | | | | No need to provide a default function name for function called from within rdbms library, it should be easy to provide always the argument Change-Id: Id9ad3a93e9d5d1c90dd9dfcb442d761c67ba951b
* / Fix DatabasePostgres::indexInfo()Tim Starling2024-09-251-2/+11
|/ | | | | | | | | | | I hit an upgrade failure due to an index which didn't exist in the schema being upgraded, although it did exist in another schema in the same database. The pg_indexes system view gives information about all indexes in the database. So, have indexInfo() return information only about the core schema. Change-Id: Idfe3bfac981e29b772860a429786f3fa3e53bbc3
* Pass function name to IDatabase functionsUmherirrender2024-09-191-2/+2
| | | | Change-Id: Ie2a1e5052e5b61bbb5b89905de942f47d3f1413d
* Merge "rdbms: clarify ownership and connection-specificity concepts"jenkins-bot2024-09-193-6/+28
|\
| * rdbms: clarify ownership and connection-specificity conceptsAaron Schulz2024-09-183-6/+28
| | | | | | | | | | | | | | | | | | Update the class/interface description comments. Mark FLUSHING_ALL_PEERS/FLUSHING_INTERNAL as internal. Bug: T373655 Change-Id: Id6048bdb1b4d0ff92ae307f154b35154a03733ec
* | rdbms: make table name parameter comments more complete and uniformAaron Schulz2024-09-094-29/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | Better emphasize that there should only be one string that callers use to reference a given table. This is what ChangedTablesTracker relies on for write queries. For read queries, databases can be vertically sharded on different servers or remapped using virtual domains, so the use of "db.table" notation should be discouraged there as well. Mention that "information_schema." is allowed as well as unqualified table names. Change-Id: I0b6295d0dd58aafd09a5c99aaf0ae9a81641d55a
* | Merge "rdbms: merge isClean() into popAtomicLevels() in TransactionManager"jenkins-bot2024-09-072-4/+5
|\ \
| * | rdbms: merge isClean() into popAtomicLevels() in TransactionManagerAaron Schulz2024-08-212-4/+5
| |/ | | | | | | Change-Id: I293584056d5b4903b5fc67632a93171997d6dc0d
* | build: Use inline ignore for Generic.CodeAnalysis.AssignmentInConditionUmherirrender2024-09-012-0/+2
| | | | | | | | | | | | | | | | | | | | | | Avoid that new code contains this pattern. Depends-On: I7a9b5c89129fe4b555d03861f2c3ce3e9e2b2446 Depends-On: Ic2bcc7eeb16d3333dcd019bd209bd7fde843dab9 Depends-On: If20eddd8376ae2e8e29c4e56cd51f7b8eb6642b0 Depends-On: I3414f7e17f4bcb801857bc986bae8eb97aa2bfb8 Depends-On: I38b2729418e8389c681c6cd84858f5e5ed25bd3e Change-Id: I7cfd2e027edd327cf8be6471e348c137fefacda0
* | Merge "rdbms: remove deprecated MaintainableDBConnRef class"jenkins-bot2024-08-301-10/+0
|\ \