Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/extension_custom_scripts.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,24 @@
#include <storage/fd.h>
#include <sys/stat.h>

/* Link against __xstat so the module loads on glibc older than 2.33. */
#if defined(__linux__) && defined(__GLIBC__) && \
(defined(__x86_64__) || defined(__aarch64__))
# if defined(__x86_64__)
# define SUPAUTILS_STAT_COMPAT_VER "GLIBC_2.2.5"
# define SUPAUTILS_STAT_VER 1
# else
# define SUPAUTILS_STAT_COMPAT_VER "GLIBC_2.17"
# define SUPAUTILS_STAT_VER 0
# endif
extern int __xstat(int ver, const char *path, struct stat *buf);
__asm__(".symver __xstat,__xstat@" SUPAUTILS_STAT_COMPAT_VER);
# undef stat
# define stat(path, buf) __xstat(SUPAUTILS_STAT_VER, path, buf)
# undef stat64
# define stat64(path, buf) __xstat(SUPAUTILS_STAT_VER, path, buf)
#endif
Comment on lines +6 to +22

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.

This is quite strange. @AndrewJackson2020 Have you seen any other extensions that do this? Is this something that has to be fixed in xpg in some other way maybe?

@AndrewJackson2020 AndrewJackson2020 Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't know. I think first step is that we should get XPG to do postgres builds with non bleeding edge libc so we can experiment with this reproducibly. In the long term I would like to see one CI job for an old libc on all of the supabase extension repos.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is only required for supautils because it needs to run on Ubuntu 20.04 but build against latest glibc. Currently we patch it in postgres repo, this PR is to upstream the patch.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This root cause is the way we ship supautils to prod via Salt. We build a single version (one per architecture) which we ship across the fleet. Ideally we should have different versions build for different ubuntu versions requiring appropriate glibc versions.

This is ugly because it depends on glibc internals and the patch would probably grow in size if we start using more symbols from glibc. I'm not sure why it's needed to build supautils in the postgres repo though.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I have another PR where im trying to implement testing in rockylinux 8, 9, and 10 for the sake of testing our code against various glitch's. I have not been able to get all tests passing in supautils though I think this s because of differential behavior of extension versions used in tests. Either way all generations of rockylinux are able to compile without issues.

#280

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This depends on glibc internals but is forward compatible forever.
We need to maintain this for about a year, until pg 15 is EOL. By that time Ubuntu 20.04 is EOL and Rocky 9 is End of Active Support and we retire all hosts from that era.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is just a symptom of the bigger problem. We might remove this specific patch but that doesn't fix the underlying cause. We might have to create another similar patch in future as long as we continue to ship supautils as today.


/*
* A list of extension names which are currently under creation.
* Used to detect cyclic dependencies between extensions via
Expand Down
Loading