Skip to content

[#415] Implemented the translation and filtering - #508

Merged
jesperpedersen merged 1 commit into
pgmoneta:mainfrom
Mohab96:feat/translate-option
Apr 3, 2025
Merged

jesperpedersen merged 1 commit into
pgmoneta:mainfrom
Mohab96:feat/translate-option

Conversation

@Mohab96

@Mohab96 Mohab96 commented Mar 9, 2025

Copy link
Copy Markdown
Collaborator

Resolves #415

Now the user can type his OID mappings in json file and run this command to get the names of relations, databases, or tablespaces in the description of the XLOG records by running this command:

pgmoneta-walinfo --translate --mapping mapping.json walfile

and if --mapping was missing it will use /etc/pgmoneta/pgmoneta_walinfo_conf.json by default.

@Mohab96

Mohab96 commented Mar 9, 2025

Copy link
Copy Markdown
Collaborator Author

I will update the parsing function and the lookup functions as well to use the ART instead of linear solution and update the branch tomorrow.

@Mohab96
Mohab96 force-pushed the feat/translate-option branch from 1fa3f77 to adfa009 Compare March 9, 2025 03:01
@Mohab96

Mohab96 commented Mar 9, 2025

Copy link
Copy Markdown
Collaborator Author

When it reached the part that I wanted to update, the rm_desc that will appear to the user, I had two tradeoffs to choose between:

Solution 1: Take the final result that will be shown to the user and start parsing and identifying the parts where oid/rel/etc appear and remove them from the string and update the string with the mapping. This solution had lots of edge cases that might pop up and will also be complex enough.

Solution 2: Search through the function that generates the description attached with every resource manager (fortunately, they were all here) and update the parts that need to be updated. This solution is a lot easier but will require changes in multiple places.

I decided to go with the second option because it is obvious what was added/removed and easy to catch the origins of the mistake if anything went wrong. It may not be the best option, but I wanted to explain my thought process also so that all of us are on the same page.

@jesperpedersen
jesperpedersen self-requested a review March 9, 2025 07:02
@jesperpedersen jesperpedersen added the feature New feature label Mar 9, 2025
@jesperpedersen

Copy link
Copy Markdown
Member

You need to update the documentation

@Mohab96

Mohab96 commented Mar 9, 2025

Copy link
Copy Markdown
Collaborator Author

I am on it.

@Mohab96
Mohab96 force-pushed the feat/translate-option branch from adfa009 to 6308e64 Compare March 9, 2025 14:40
@Mohab96

Mohab96 commented Mar 9, 2025

Copy link
Copy Markdown
Collaborator Author

I updated the docs.

@Mohab96

Mohab96 commented Mar 9, 2025

Copy link
Copy Markdown
Collaborator Author

@jesperpedersen @Jubilee101 @sh-soltanpour

Can you provide any hints on which APIs I should use to fetch metadata from the server directly?
I know I should use the shmem to get the data from the config file, but how can I use things in the [primary] section in the config to fetch metadata from the server? I think also maybe there are APIs that I can get this info from directly.

I was searching in files like message.h, server.h, and http.h, but I couldn't figure it out yet.

@jesperpedersen

Copy link
Copy Markdown
Member

@Mohab96 I would just start simple and do new functions in message.h

Otherwise you can look at porting parts of queries.h from pgexporter over and use that. For the OIDs and their ARTs, I think that would be process only, and not in shmem

@Mohab96
Mohab96 force-pushed the feat/translate-option branch from 6308e64 to 197938a Compare March 10, 2025 04:32
@Mohab96

Mohab96 commented Mar 10, 2025

Copy link
Copy Markdown
Collaborator Author

I pushed the patch @jesperpedersen @sh-soltanpour

  1. Used the pgmoneta_users.conf in walinfo.
  2. The feature is working and tested from the mapping.json file and the server using pgbench.
  3. There's a memory leak caused by line walinfo.c:407 when using debug build instead of release build. Of course, I will not push such dangerous code to the repo directly, so I wanted to mention that so that it doesn't get merged by accident and this problem go unnoticed but I did this so that I can get review on the code written until now and I will work on this memory problem in the meantime. I just wanted to buy time so I would not delay the review because of this problem.

I will finish the docs after getting approval on the feature itself so that I don't have to update the docs every time I update the feature.

Comment thread doc/manual/dev-06-wal.md Resolved
Comment thread src/include/wal.h Resolved
Comment thread src/include/wal.h Resolved
Comment thread src/include/wal.h Resolved
Comment thread src/include/wal.h Outdated
} OidMapping;

extern OidMapping* oidMappings;
extern int mappings_size;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you clarify more?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you wanted me to remove them from wal.h as they are not needed outside wal.c, right?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use parameters instead - in and out

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eventually I will need to make them global because I need the lookup functions in every resource manager to have access to this object which is available globally.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shared deque ? We are in-process so it is the same memory context...

@sh-soltanpour Ideas ?

Comment thread src/libpgmoneta/wal.c Resolved
Comment thread src/libpgmoneta/wal.c Resolved
Comment thread src/libpgmoneta/wal.c Resolved
Comment thread src/libpgmoneta/wal.c Resolved
Comment thread src/libpgmoneta/wal.c Resolved
@jesperpedersen

Copy link
Copy Markdown
Member

I'll continue later

@Mohab96
Mohab96 force-pushed the feat/translate-option branch 2 times, most recently from 75d7e23 to c78adc1 Compare March 10, 2025 22:57
@Mohab96

Mohab96 commented Mar 11, 2025

Copy link
Copy Markdown
Collaborator Author

I finished this feature and updated the docs, you can review them now if you want. @jesperpedersen

Comment thread doc/manual/dev-06-wal.md Resolved
Comment thread doc/manual/dev-06-wal.md Resolved
Comment thread doc/manual/dev-06-wal.md Resolved
Comment thread src/include/wal.h Resolved
Comment thread src/include/wal.h Resolved
Comment thread src/libpgmoneta/walfile/rm_btree.c Resolved
Comment thread src/libpgmoneta/walfile/rm_btree.c Resolved
Comment thread src/libpgmoneta/walfile/rm_heap.c Resolved
Comment thread src/libpgmoneta/walfile/rm_xlog.c Resolved
Comment thread src/walinfo.c Resolved
@jesperpedersen

Copy link
Copy Markdown
Member

See CI...

You should do a pgmoneta_walinfo.conf file with the minimum configuration, and document it. See how pgagroal does it.

Start with this, and I will circle back

@jesperpedersen

Copy link
Copy Markdown
Member

You can do the configuration split (common, main, walinfo) in a separate pull request as you want

@jesperpedersen

Copy link
Copy Markdown
Member

Uncrustify_d-0.78.1_f here

@Mohab96
Mohab96 force-pushed the feat/translate-option branch 2 times, most recently from b896a7d to 41de97c Compare March 11, 2025 19:07
@Mohab96

Mohab96 commented Mar 11, 2025

Copy link
Copy Markdown
Collaborator Author

You can do the configuration split (common, main, walinfo) in a separate pull request as you want

The way config files are configured in pgagroal is nice, but I think I will move this to another PR and focus in this PR on the main feature I need to deliver

@Mohab96

Mohab96 commented Mar 11, 2025

Copy link
Copy Markdown
Collaborator Author

Uncrustify_d-0.78.1_f here

mohab@apollo:~$ uncrustify -v
Uncrustify-0.78.1_f

@Mohab96

Mohab96 commented Mar 11, 2025

Copy link
Copy Markdown
Collaborator Author

You should do a pgmoneta_walinfo.conf file with the minimum configuration, and document it. See how pgagroal does it.

Currently, walinfo is "working" with pgmoneta.conf. Can I assume that the minimal configurations needed for walinfo (separate from pgmoneta) are a subset of pgmoneta.conf?

If so, this will save a lot of time, allowing me to filter out the configurations that are irrelevant to walinfo and document those that remain after this filtering.

@jesperpedersen

Copy link
Copy Markdown
Member

@Mohab96 Yes, there will be a minimal "common", a "main" and a "walinfo", and ... so like pgagroal

@Mohab96 Mohab96 changed the title [#415] Implemented the option with mapping file [#415] Implemented the translate option Mar 12, 2025
@Mohab96

Mohab96 commented Apr 2, 2025

Copy link
Copy Markdown
Collaborator Author

I'll give it a shot.

@jesperpedersen

Copy link
Copy Markdown
Member

@sh-soltanpour What are you seeing ?

@sh-soltanpour

Copy link
Copy Markdown
Collaborator

@sh-soltanpour What are you seeing ?

In file included from /Users/shahryarsoltanpour/Programming/pgmoneta/src/libpgmoneta/security.c:41:
/Library/Developer/CommandLineTools/usr/lib/clang/16/include/nmmintrin.h:14:2: error: "This header is only meant to be used on x86 and x64 architecture"
   14 | #error "This header is only meant to be used on x86 and x64 architecture"
      |  ^
In file included from /Users/shahryarsoltanpour/Programming/pgmoneta/src/libpgmoneta/security.c:41:
In file included from /Library/Developer/CommandLineTools/usr/lib/clang/16/include/nmmintrin.h:19:
/Library/Developer/CommandLineTools/usr/lib/clang/16/include/smmintrin.h:14:2: error: "This header is only meant to be used on x86 and x64 architecture"
   14 | #error "This header is only meant to be used on x86 and x64 architecture"
      |  ^
In file included from /Users/shahryarsoltanpour/Programming/pgmoneta/src/libpgmoneta/security.c:41:
In file included from /Library/Developer/CommandLineTools/usr/lib/clang/16/include/nmmintrin.h:19:
In file included from /Library/Developer/CommandLineTools/usr/lib/clang/16/include/smmintrin.h:17:
/Library/Developer/CommandLineTools/usr/lib/clang/16/include/tmmintrin.h:14:2: error: "This header is only meant to be used on x86 and x64 architecture"
   14 | #error "This header is only meant to be used on x86 and x64 architecture"
      |  ^
In file included from /Users/shahryarsoltanpour/Programming/pgmoneta/src/libpgmoneta/security.c:41:
In file included from /Library/Developer/CommandLineTools/usr/lib/clang/16/include/nmmintrin.h:19:
In file included from /Library/Developer/CommandLineTools/usr/lib/clang/16/include/smmintrin.h:17:
In file included from /Library/Developer/CommandLineTools/usr/lib/clang/16/include/tmmintrin.h:17:
/Library/Developer/CommandLineTools/usr/lib/clang/16/include/pmmintrin.h:14:2: error: "This header is only meant to be used on x86 and x64 architecture"
   14 | #error "This header is only meant to be used on x86 and x64 architecture"
      |  ^
In file included from /Users/shahryarsoltanpour/Programming/pgmoneta/src/libpgmoneta/security.c:41:
In file included from /Library/Developer/CommandLineTools/usr/lib/clang/16/include/nmmintrin.h:19:
In file included from /Library/Developer/CommandLineTools/usr/lib/clang/16/include/smmintrin.h:17:
In file included from /Library/Developer/CommandLineTools/usr/lib/clang/16/include/tmmintrin.h:17:
In file included from /Library/Developer/CommandLineTools/usr/lib/clang/16/include/pmmintrin.h:17:
/Library/Developer/CommandLineTools/usr/lib/clang/16/include/emmintrin.h:14:2: error: "This header is only meant to be used on x86 and x64 architecture"
   14 | #error "This header is only meant to be used on x86 and x64 architecture"
      |  ^
In file included from /Users/shahryarsoltanpour/Programming/pgmoneta/src/libpgmoneta/security.c:41:
In file included from /Library/Developer/CommandLineTools/usr/lib/clang/16/include/nmmintrin.h:19:
In file included from /Library/Developer/CommandLineTools/usr/lib/clang/16/include/smmintrin.h:17:
In file included from /Library/Developer/CommandLineTools/usr/lib/clang/16/include/tmmintrin.h:17:
In file included from /Library/Developer/CommandLineTools/usr/lib/clang/16/include/pmmintrin.h:17:
In file included from /Library/Developer/CommandLineTools/usr/lib/clang/16/include/emmintrin.h:17:
/Library/Developer/CommandLineTools/usr/lib/clang/16/include/xmmintrin.h:14:2: error: "This header is only meant to be used on x86 and x64 architecture"
   14 | #error "This header is only meant to be used on x86 and x64 architecture"
      |  ^
In file included from /Users/shahryarsoltanpour/Programming/pgmoneta/src/libpgmoneta/security.c:41:
In file included from /Library/Developer/CommandLineTools/usr/lib/clang/16/include/nmmintrin.h:19:
In file included from /Library/Developer/CommandLineTools/usr/lib/clang/16/include/smmintrin.h:17:
In file included from /Library/Developer/CommandLineTools/usr/lib/clang/16/include/tmmintrin.h:17:
In file included from /Library/Developer/CommandLineTools/usr/lib/clang/16/include/pmmintrin.h:17:
In file included from /Library/Developer/CommandLineTools/usr/lib/clang/16/include/emmintrin.h:17:
In file included from /Library/Developer/CommandLineTools/usr/lib/clang/16/include/xmmintrin.h:17:
/Library/Developer/CommandLineTools/usr/lib/clang/16/include/mmintrin.h:14:2: error: "This header is only meant to be used on x86 and x64 architecture"
   14 | #error "This header is only meant to be used on x86 and x64 architecture"
      |  ^
/Library/Developer/CommandLineTools/usr/lib/clang/16/include/mmintrin.h:54:12: error: invalid conversion between vector type '__m64' (vector of 1 'long long' value) and integer type 'int' of different size
   54 |     return (__m64)__builtin_ia32_vec_init_v2si(__i, 0);
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/usr/lib/clang/16/include/mmintrin.h:133:12: error: invalid conversion between vector type '__m64' (vector of 1 'long long' value) and integer type 'int' of different size
  133 |     return (__m64)__builtin_ia32_packsswb((__v4hi)__m1, (__v4hi)__m2);
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/usr/lib/clang/16/include/mmintrin.h:163:12: error: invalid conversion between vector type '__m64' (vector of 1 'long long' value) and integer type 'int' of different size
  163 |     return (__m64)__builtin_ia32_packssdw((__v2si)__m1, (__v2si)__m2);
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/usr/lib/clang/16/include/mmintrin.h:193:12: error: invalid conversion between vector type '__m64' (vector of 1 'long long' value) and integer type 'int' of different size
  193 |     return (__m64)__builtin_ia32_packuswb((__v4hi)__m1, (__v4hi)__m2);
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/usr/lib/clang/16/include/mmintrin.h:220:12: error: invalid conversion between vector type '__m64' (vector of 1 'long long' value) and integer type 'int' of different size
  220 |     return (__m64)__builtin_ia32_punpckhbw((__v8qi)__m1, (__v8qi)__m2);
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/usr/lib/clang/16/include/mmintrin.h:243:12: error: invalid conversion between vector type '__m64' (vector of 1 'long long' value) and integer type 'int' of different size
  243 |     return (__m64)__builtin_ia32_punpckhwd((__v4hi)__m1, (__v4hi)__m2);
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/usr/lib/clang/16/include/mmintrin.h:264:12: error: invalid conversion between vector type '__m64' (vector of 1 'long long' value) and integer type 'int' of different size
  264 |     return (__m64)__builtin_ia32_punpckhdq((__v2si)__m1, (__v2si)__m2);
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/usr/lib/clang/16/include/mmintrin.h:291:12: error: invalid conversion between vector type '__m64' (vector of 1 'long long' value) and integer type 'int' of different size
  291 |     return (__m64)__builtin_ia32_punpcklbw((__v8qi)__m1, (__v8qi)__m2);
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/usr/lib/clang/16/include/mmintrin.h:314:12: error: invalid conversion between vector type '__m64' (vector of 1 'long long' value) and integer type 'int' of different size
  314 |     return (__m64)__builtin_ia32_punpcklwd((__v4hi)__m1, (__v4hi)__m2);
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/usr/lib/clang/16/include/mmintrin.h:335:12: error: invalid conversion between vector type '__m64' (vector of 1 'long long' value) and integer type 'int' of different size
  335 |     return (__m64)__builtin_ia32_punpckldq((__v2si)__m1, (__v2si)__m2);
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/usr/lib/clang/16/include/mmintrin.h:356:12: error: invalid conversion between vector type '__m64' (vector of 1 'long long' value) and integer type 'int' of different size
  356 |     return (__m64)__builtin_ia32_paddb((__v8qi)__m1, (__v8qi)__m2);
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/usr/lib/clang/16/include/mmintrin.h:377:12: error: invalid conversion between vector type '__m64' (vector of 1 'long long' value) and integer type 'int' of different size
  377 |     return (__m64)__builtin_ia32_paddw((__v4hi)__m1, (__v4hi)__m2);
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make[2]: *** [src/CMakeFiles/pgmoneta.dir/libpgmoneta/security.c.o] Error 1
make[1]: *** [src/CMakeFiles/pgmoneta.dir/all] Error 2
make: *** [all] Error 2

@Mohab96

Mohab96 commented Apr 2, 2025

Copy link
Copy Markdown
Collaborator Author

oh okay I see, can you add it here and test? The last PR merged to main has broken the builds on macos so I can't get the project running atm

I added these lines at the end of the function

   ptr += sizeof(transaction_id);
   memcpy(&wrapper->data.v17.time, ptr, sizeof(pg_time_t));

and this is the output before and after I added them

pgmoneta@apollo:~$ pgmoneta-walinfo -t 00000001000000000000001D.gz
XLOG | 0/1C700F68 | 0/1D000028 | 30 | 30 | 0 |
Standby | 0/1D000028 | 0/1D000048 | 50 | 50 | 0 | next_xid 52236 latest_completed_xid 52235 oldest_running_xid 52236
XLOG | 0/1D000048 | 0/1D000080 | 114 | 114 | 0 | redo 0/1D000028; tli 1; prev tli 1; fpw true; wal_level ?; xid 204:201326592; oid 285212672; multi 16777312; offset 0; oldest xid 3657433088 in DB 16777218; oldest multi 16777216 in DB 16777216; oldest/newest commit timestamp xid: 0/2130706432; oldest running xid 6810514 online
Standby | 0/1D000080 | 0/1D0000F8 | 50 | 50 | 0 | next_xid 52236 latest_completed_xid 52235 oldest_running_xid 52236
XLOG | 0/1D0000F8 | 0/1D000130 | 34 | 34 | 0 | 0/1D000028
XLOG | 0/1D000130 | 0/1D000158 | 24 | 24 | 0 |
pgmoneta@apollo:~$ pgmoneta-walinfo -t 00000001000000000000001D.gz
XLOG | 0/1C700F68 | 0/1D000028 | 30 | 30 | 0 |
Standby | 0/1D000028 | 0/1D000048 | 50 | 50 | 0 | next_xid 52236 latest_completed_xid 52235 oldest_running_xid 52236
XLOG | 0/1D000048 | 0/1D000080 | 114 | 114 | 0 | redo 0/1D000028; tli 1; prev tli 1; fpw true; wal_level ?; xid 204:201326592; oid 285212672; multi 16777312; offset 0; oldest xid 3657433088 in DB 16777218; oldest multi 16777216 in DB 16777216; oldest/newest commit timestamp xid: 0/2130706432; oldest running xid 6810514 online
Standby | 0/1D000080 | 0/1D0000F8 | 50 | 50 | 0 | next_xid 52236 latest_completed_xid 52235 oldest_running_xid 52236
XLOG | 0/1D0000F8 | 0/1D000130 | 34 | 34 | 0 | 0/1D000028
XLOG | 0/1D000130 | 0/1D000158 | 24 | 24 | 0 |
pgmoneta@apollo:~$

@sh-soltanpour

Copy link
Copy Markdown
Collaborator

not at the end, just at the order it appears in the struct defnition

@Mohab96

Mohab96 commented Apr 2, 2025

Copy link
Copy Markdown
Collaborator Author

I kinda know what caused this problem. I will send a fix to it now in a separate PR, and please test that branch before merging.

@Mohab96

Mohab96 commented Apr 2, 2025

Copy link
Copy Markdown
Collaborator Author
pgmoneta@apollo:~$ pgmoneta-walinfo -t 00000001000000000000001D.gz
XLOG | 0/1C700F68 | 0/1D000028 | 30 | 30 | 0 |
Standby | 0/1D000028 | 0/1D000048 | 50 | 50 | 0 | next_xid 52236 latest_completed_xid 52235 oldest_running_xid 52236
XLOG | 0/1D000048 | 0/1D000080 | 114 | 114 | 0 | redo 0/1D000028; tli 1; prev tli 1; fpw true; wal_level ?; xid 204:201326592; oid 285212672; multi 16777312; offset 0; oldest xid 3657433088 in DB 16777218; oldest multi 16777216 in DB 16777216; oldest/newest commit timestamp xid: 6810514/0; oldest running xid 0 online
Standby | 0/1D000080 | 0/1D0000F8 | 50 | 50 | 0 | next_xid 52236 latest_completed_xid 52235 oldest_running_xid 52236
XLOG | 0/1D0000F8 | 0/1D000130 | 34 | 34 | 0 | 0/1D000028
XLOG | 0/1D000130 | 0/1D000158 | 24 | 24 | 0 |
pgmoneta@apollo:~$
void
check_point_parse_v17(struct check_point* wrapper, void* rec)
{
   char* ptr = (char*)rec;
   memcpy(&wrapper->data.v17.redo, ptr, sizeof(xlog_rec_ptr));
   ptr += sizeof(xlog_rec_ptr);
   memcpy(&wrapper->data.v17.this_timeline_id, ptr, sizeof(uint32_t));
   ptr += sizeof(uint32_t);
   memcpy(&wrapper->data.v17.prev_timeline_id, ptr, sizeof(uint32_t));
   ptr += sizeof(uint32_t);
   memcpy(&wrapper->data.v17.full_page_writes, ptr, sizeof(bool));
   ptr += sizeof(bool);
   memcpy(&wrapper->data.v17.wal_level, ptr, sizeof(int));
   ptr += sizeof(int);
   memcpy(&wrapper->data.v17.next_xid, ptr, sizeof(struct full_transaction_id));
   ptr += sizeof(struct full_transaction_id);
   memcpy(&wrapper->data.v17.next_oid, ptr, sizeof(oid));
   ptr += sizeof(oid);
   memcpy(&wrapper->data.v17.next_multi, ptr, sizeof(multi_xact_id));
   ptr += sizeof(multi_xact_id);
   memcpy(&wrapper->data.v17.next_multi_offset, ptr, sizeof(multi_xact_offset));
   ptr += sizeof(multi_xact_offset);
   memcpy(&wrapper->data.v17.oldest_xid, ptr, sizeof(transaction_id));
   ptr += sizeof(transaction_id);
   memcpy(&wrapper->data.v17.oldest_xid_db, ptr, sizeof(oid));
   ptr += sizeof(oid);
   memcpy(&wrapper->data.v17.oldest_multi, ptr, sizeof(multi_xact_id));
   ptr += sizeof(multi_xact_id);
   memcpy(&wrapper->data.v17.oldest_multi_db, ptr, sizeof(oid));
   ptr += sizeof(oid);
->   memcpy(&wrapper->data.v17.time, ptr, sizeof(pg_time_t));
->   ptr += sizeof(pg_time_t);
   memcpy(&wrapper->data.v17.oldest_commit_ts_xid, ptr, sizeof(transaction_id));
   ptr += sizeof(transaction_id);
   memcpy(&wrapper->data.v17.newest_commit_ts_xid, ptr, sizeof(transaction_id));
   ptr += sizeof(transaction_id);
   memcpy(&wrapper->data.v17.oldest_active_xid, ptr, sizeof(transaction_id));
}

@jesperpedersen

Copy link
Copy Markdown
Member

@Mohab96 Can you look at the PCLMUL on Mac problem too ? Maybe just guard with HAVE_LINUX

@Mohab96

Mohab96 commented Apr 2, 2025

Copy link
Copy Markdown
Collaborator Author

@Mohab96 Can you look at the PCLMUL on Mac problem too ? Maybe just guard with HAVE_LINUX

I think the two headers I added should be guarded, that's it. I will send a patch in a moment.

@jesperpedersen

Copy link
Copy Markdown
Member

👍 just reuse the issue number

@Mohab96

Mohab96 commented Apr 2, 2025

Copy link
Copy Markdown
Collaborator Author

I don't understand what the output of this file should be or what the problem is with it. Can you clarify? @jesperpedersen

@sh-soltanpour

Copy link
Copy Markdown
Collaborator

I don't understand what the output of this file should be or what the problem is with it. Can you clarify? @jesperpedersen

This is the expected output from pg_waldump. So adding that time variable didn't help.

rmgr: XLOG        len (rec/tot):     30/    30, tx:          0, lsn: 0/1D000028, prev 0/1C700F68, desc: CHECKPOINT_REDO wal_level replica
rmgr: Standby     len (rec/tot):     50/    50, tx:          0, lsn: 0/1D000048, prev 0/1D000028, desc: RUNNING_XACTS nextXid 52236 latestCompletedXid 52235 oldestRunningXid 52236
rmgr: XLOG        len (rec/tot):    114/   114, tx:          0, lsn: 0/1D000080, prev 0/1D000048, desc: CHECKPOINT_ONLINE redo 0/1D000028; tli 1; prev tli 1; fpw true; wal_level replica; xid 0:52236; oid 24593; multi 1; offset 0; oldest xid 730 in DB 1; oldest multi 1 in DB 1; oldest/newest commit timestamp xid: 0/0; oldest running xid 52236; online
rmgr: Standby     len (rec/tot):     50/    50, tx:          0, lsn: 0/1D0000F8, prev 0/1D000080, desc: RUNNING_XACTS nextXid 52236 latestCompletedXid 52235 oldestRunningXid 52236
rmgr: XLOG        len (rec/tot):     34/    34, tx:          0, lsn: 0/1D000130, prev 0/1D0000F8, desc: BACKUP_END 0/1D000028
rmgr: XLOG        len (rec/tot):     24/    24, tx:          0, lsn: 0/1D000158, prev 0/1D000130, desc: SWITCH 

@Mohab96

Mohab96 commented Apr 2, 2025

Copy link
Copy Markdown
Collaborator Author

This solution works, but at this point, I am not sure whether it is okay to use it for this situation.

#include <stddef.h>

void
check_point_parse_v17(struct check_point* wrapper, void* rec)
{
   char* ptr = (char*)rec;

   // Copy each member using precise offset calculations
   memcpy(&wrapper->data.v17.redo,
          ptr + offsetof(struct check_point_v17, redo),
          sizeof(xlog_rec_ptr));

   memcpy(&wrapper->data.v17.this_timeline_id,
          ptr + offsetof(struct check_point_v17, this_timeline_id),
          sizeof(timeline_id));

   memcpy(&wrapper->data.v17.prev_timeline_id,
          ptr + offsetof(struct check_point_v17, prev_timeline_id),
          sizeof(timeline_id));

   memcpy(&wrapper->data.v17.full_page_writes,
          ptr + offsetof(struct check_point_v17, full_page_writes),
          sizeof(bool));

   memcpy(&wrapper->data.v17.wal_level,
          ptr + offsetof(struct check_point_v17, wal_level),
          sizeof(int));

   memcpy(&wrapper->data.v17.next_oid,
          ptr + offsetof(struct check_point_v17, next_oid),
          sizeof(oid));

   memcpy(&wrapper->data.v17.next_multi,
          ptr + offsetof(struct check_point_v17, next_multi),
          sizeof(multi_xact_id));

   memcpy(&wrapper->data.v17.next_multi_offset,
          ptr + offsetof(struct check_point_v17, next_multi_offset),
          sizeof(multi_xact_offset));

   memcpy(&wrapper->data.v17.oldest_xid,
          ptr + offsetof(struct check_point_v17, oldest_xid),
          sizeof(transaction_id));

   memcpy(&wrapper->data.v17.oldest_xid_db,
          ptr + offsetof(struct check_point_v17, oldest_xid_db),
          sizeof(oid));

   memcpy(&wrapper->data.v17.oldest_multi,
          ptr + offsetof(struct check_point_v17, oldest_multi),
          sizeof(multi_xact_id));

   memcpy(&wrapper->data.v17.oldest_multi_db,
          ptr + offsetof(struct check_point_v17, oldest_multi_db),
          sizeof(oid));

   memcpy(&wrapper->data.v17.time,
          ptr + offsetof(struct check_point_v17, time),
          sizeof(pg_time_t));

   memcpy(&wrapper->data.v17.oldest_commit_ts_xid,
          ptr + offsetof(struct check_point_v17, oldest_commit_ts_xid),
          sizeof(transaction_id));

   memcpy(&wrapper->data.v17.newest_commit_ts_xid,
          ptr + offsetof(struct check_point_v17, newest_commit_ts_xid),
          sizeof(transaction_id));

   memcpy(&wrapper->data.v17.oldest_active_xid,
          ptr + offsetof(struct check_point_v17, oldest_active_xid),
          sizeof(transaction_id));

   memcpy(&wrapper->data.v17.next_xid,
          ptr + offsetof(struct check_point_v17, next_xid),
          sizeof(struct full_transaction_id));
}

@jesperpedersen @sh-soltanpour

@Mohab96
Mohab96 force-pushed the feat/translate-option branch from 85955b3 to 0795de0 Compare April 2, 2025 18:06
@Mohab96

Mohab96 commented Apr 2, 2025

Copy link
Copy Markdown
Collaborator Author

Is it okay to just do this for now?

wrapper->data.v17 = *((struct check_point_v17*)rec);
return;

@jesperpedersen @sh-soltanpour

@jesperpedersen

Copy link
Copy Markdown
Member

@Mohab96 I think it would be ok

Now, we just have to figure out the wal_level issue and the missing OIDs

@sh-soltanpour

Copy link
Copy Markdown
Collaborator

This solution works, but at this point, I am not sure whether it is okay to use it for this situation.

#include <stddef.h>

void
check_point_parse_v17(struct check_point* wrapper, void* rec)
{
   char* ptr = (char*)rec;

   // Copy each member using precise offset calculations
   memcpy(&wrapper->data.v17.redo,
          ptr + offsetof(struct check_point_v17, redo),
          sizeof(xlog_rec_ptr));

   memcpy(&wrapper->data.v17.this_timeline_id,
          ptr + offsetof(struct check_point_v17, this_timeline_id),
          sizeof(timeline_id));

   memcpy(&wrapper->data.v17.prev_timeline_id,
          ptr + offsetof(struct check_point_v17, prev_timeline_id),
          sizeof(timeline_id));

   memcpy(&wrapper->data.v17.full_page_writes,
          ptr + offsetof(struct check_point_v17, full_page_writes),
          sizeof(bool));

   memcpy(&wrapper->data.v17.wal_level,
          ptr + offsetof(struct check_point_v17, wal_level),
          sizeof(int));

   memcpy(&wrapper->data.v17.next_oid,
          ptr + offsetof(struct check_point_v17, next_oid),
          sizeof(oid));

   memcpy(&wrapper->data.v17.next_multi,
          ptr + offsetof(struct check_point_v17, next_multi),
          sizeof(multi_xact_id));

   memcpy(&wrapper->data.v17.next_multi_offset,
          ptr + offsetof(struct check_point_v17, next_multi_offset),
          sizeof(multi_xact_offset));

   memcpy(&wrapper->data.v17.oldest_xid,
          ptr + offsetof(struct check_point_v17, oldest_xid),
          sizeof(transaction_id));

   memcpy(&wrapper->data.v17.oldest_xid_db,
          ptr + offsetof(struct check_point_v17, oldest_xid_db),
          sizeof(oid));

   memcpy(&wrapper->data.v17.oldest_multi,
          ptr + offsetof(struct check_point_v17, oldest_multi),
          sizeof(multi_xact_id));

   memcpy(&wrapper->data.v17.oldest_multi_db,
          ptr + offsetof(struct check_point_v17, oldest_multi_db),
          sizeof(oid));

   memcpy(&wrapper->data.v17.time,
          ptr + offsetof(struct check_point_v17, time),
          sizeof(pg_time_t));

   memcpy(&wrapper->data.v17.oldest_commit_ts_xid,
          ptr + offsetof(struct check_point_v17, oldest_commit_ts_xid),
          sizeof(transaction_id));

   memcpy(&wrapper->data.v17.newest_commit_ts_xid,
          ptr + offsetof(struct check_point_v17, newest_commit_ts_xid),
          sizeof(transaction_id));

   memcpy(&wrapper->data.v17.oldest_active_xid,
          ptr + offsetof(struct check_point_v17, oldest_active_xid),
          sizeof(transaction_id));

   memcpy(&wrapper->data.v17.next_xid,
          ptr + offsetof(struct check_point_v17, next_xid),
          sizeof(struct full_transaction_id));
}

@jesperpedersen @sh-soltanpour

I like this one as well

@Mohab96

Mohab96 commented Apr 2, 2025

Copy link
Copy Markdown
Collaborator Author

I like this one as well

I think instead of blindly trying solutions that work in some situations, we should open another issue and find the root cause of the problem and try to solve it. For now, we just want to stay within the scope of this feature as much as possible.

Do you agree with me? @sh-soltanpour @jesperpedersen

@Mohab96
Mohab96 force-pushed the feat/translate-option branch from 0795de0 to 9c2627d Compare April 2, 2025 18:26
@Mohab96

Mohab96 commented Apr 2, 2025

Copy link
Copy Markdown
Collaborator Author

There's only one oid that is not translated, which is called oid and is called in two places only check_point_format_v16 and check_point_format_v17, and they are transaction IDs, not tablespace or database, or relation. @jesperpedersen

@jesperpedersen

Copy link
Copy Markdown
Member

@Mohab96 I meant on a general pgbench run...

But, we can take it separate if @sh-soltanpour agrees

@Mohab96

Mohab96 commented Apr 2, 2025

Copy link
Copy Markdown
Collaborator Author

Is there anything else leftover in this PR?

@jesperpedersen

Copy link
Copy Markdown
Member

@Mohab96 We need a sign-off from @sh-soltanpour and then we can create issues for the stuff we have found

@Mohab96
Mohab96 force-pushed the feat/translate-option branch from 9c2627d to f864b6e Compare April 2, 2025 22:27
@sh-soltanpour

Copy link
Copy Markdown
Collaborator

Member

ok agreed

@Mohab96

Mohab96 commented Apr 3, 2025

Copy link
Copy Markdown
Collaborator Author

Nice. This PR has been rebased and is ready to be approved. @jesperpedersen

@jesperpedersen
jesperpedersen merged commit f864b6e into pgmoneta:main Apr 3, 2025
@jesperpedersen

Copy link
Copy Markdown
Member

Merged.

Thanks for your contribution !

@Mohab96
Mohab96 deleted the feat/translate-option branch April 3, 2025 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

walinfo: Advanced filtering

3 participants