cloudberry icon indicating copy to clipboard operation
cloudberry copied to clipboard

[Bug] one fewer share lock than before when inserting

Open congxuebin opened this issue 1 year ago • 2 comments

Cloudberry Database version

PostgreSQL 14.4 (Cloudberry Database 1.0.0+d0add48 build commit:d0add48089f13bbaa31284ac62ab88eb79806671)

What happened

One fewer lock than before when inserting.

Actual result:

1: BEGIN;
BEGIN
1: INSERT INTO ao VALUES (200, 200);
INSERT 1
SELECT * FROM locktest;
coalesce             |      mode      |locktype
---------------------------------+----------------+--------
ao                               |RowExclusiveLock|relation
ao                               |RowExclusiveLock|relation
locktest                         |AccessShareLock |relation
pg_class                         |AccessShareLock |relation
pg_class                         |AccessShareLock |relation
pg_class_oid_index               |AccessShareLock |relation
pg_class_relname_nsp_index       |AccessShareLock |relation
pg_class_tblspc_relfilenode_index|AccessShareLock |relation
pg_locks                         |AccessShareLock |relation
(9 rows)

Expected result:

1: BEGIN;
BEGIN
1: INSERT INTO ao VALUES (200, 200);
INSERT 1
SELECT * FROM locktest;
coalesce             |      mode      |locktype
---------------------------------+----------------+--------
ao                               |RowExclusiveLock|relation
ao                               |RowExclusiveLock|relation
locktest                         |AccessShareLock |relation
pg_class                         |AccessShareLock |relation
pg_class_oid_index               |AccessShareLock |relation
pg_class_relname_nsp_index       |AccessShareLock |relation
pg_class_tblspc_relfilenode_index|AccessShareLock |relation
pg_locks                         |AccessShareLock |relation
(8 rows)

What you think should happen instead

No response

How to reproduce

tbd

Operating System

centos7

Anything else

No response

Are you willing to submit PR?

  • [ ] Yes, I am willing to submit a PR!

Code of Conduct

congxuebin avatar Aug 15 '24 03:08 congxuebin

Actual result: 9 rows, Expected result: 8 rows?

fewer lock or more locks?

avamingli avatar Aug 15 '24 05:08 avamingli

Actual result: 9 rows, Expected result: 8 rows?

I think you want to show Actual result: 8 rows, Expected result: 9 rows, right?

If so, it's called by https://github.com/cloudberrydb/cloudberrydb/pull/541

However, it's not a bug.
The pr uses syscache instead of open a table with a lock. That's expected and better to hold less locks. Such cases are not bugs, you need to adjust test cases.

avamingli avatar Aug 15 '24 05:08 avamingli

As confirmed, new code change is an enhancement that no need to keep holding one of locks. Thus I adjusted test cases to accordingly.

UAOIsolationTestCase.test_locks ... 404.31 ms ... ok UAOIsolationTestCase.test_locks_reindex ... 398.81 ms ... ok

congxuebin avatar Aug 16 '24 10:08 congxuebin